DeploymentItem 在 VS2010 和 VS2012 中的行为不同 [英] DeploymentItem behaving differently in VS2010 and VS2012
问题描述
我有一个 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(@"SubDirSubDir2models", "models")]
public class UnitTests
{ ... }
在 2010 年,它从 SolutionDirectorySubDirSubDir2models
目录中正确复制依赖文件.
In 2010, it's correctly copying dependent files from the SolutionDirectorySubDirSubDir2models
directory.
在 2012 年,它试图从部署测试的目录中复制 SolutionDirectoryUnitTestsindebugSubDirSubDir2models
In 2012, it's attempting to copy from the directory where the tests are deployed SolutionDirectoryUnitTestsindebugSubDirSubDir2models
我正在寻找恢复旧行为的方法.
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.
这篇关于DeploymentItem 在 VS2010 和 VS2012 中的行为不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!