本文介绍了在VS2010和VS2012中,DeploymentItem的行为有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VS2010解决方案,我正在尝试升级到VS2012.

I have a VS2010 solution that I'm trying to upgrade to VS2012.

我在VS2012中的MSTest单元测试中遇到问题.所有测试都在测试类上包含DeploymentItem属性.

I'm having a problem with the MSTest unit tests in VS2012. All of the tests include DeploymentItem attributes on the test class.

[TestClass]
[DeploymentItem(@"SubDir\SubDir2\models", "models")]
public class UnitTests
{ ... }

在2010年,它可以正确地从SolutionDirectory\SubDir\SubDir2\models目录复制依赖文件.

In 2010, it's correctly copying dependent files from the SolutionDirectory\SubDir\SubDir2\models directory.

2012年,它试图从部署测试的目录中复制SolutionDirectory\UnitTests\bin\debug\SubDir\SubDir2\models

In 2012, it's attempting to copy from the directory where the tests are deployed SolutionDirectory\UnitTests\bin\debug\SubDir\SubDir2\models

我正在寻找一种还原旧行为的方法.

I'm looking for a way to restore the old behavior.

推荐答案

如果在解决方案中创建测试设置文件,请在其中启用部署(默认情况下,测试设置中的部署处于关闭状态),然后在测试浏览器中将其选中(测试->测试设置->选择测试设置文件),那么它也应该工作而无需更改代码.

If you create a test settings file in your solution, enable deployment in it (by default deployment is off in the test settings) and select it in the test explorer (Test -> Test Settings -> Select test settings file), then it should work without changing the code as well.

这篇关于在VS2010和VS2012中,DeploymentItem的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:05