Kir*_*ril 5 c# msbuild dependencies visual-studio-2010 visual-studio
我的项目依赖于我通常通过MSBuild目标复制到输出目录的一些本机库(DLL).运行应用程序时没有问题,但我在Visual Studio中编写了一些单元测试,每次运行单元测试时,程序集和可执行文件都会从输出目录复制到staging文件夹中:C:\path\to\MyProject\TestResults\myWorkStationName 2012-03-20 13_53_56\Out
遗憾的是,本机DLL不会复制到暂存目录中,并且会在每次测试运行时生成暂存目录.是否有一个MSbuild目标允许我将东西复制到临时目录?
PS我不确定"staging目录"是否是正确的术语,所以请原谅我的无知,如果不是:).
从 VS 菜单:Test> Edit Test Settings> (settings file)> Deployment> 检查Enable deployment并添加目录或文件。
请注意此功能中的一个警告:在 Visual Studio 重新启动之前,现有测试的启用部署将无法工作。

使用[DeploymentItem]属性:
[TestMethod()]
[DeploymentItem("testFile1.txt")]
public void ConstructorTest()
{
// Create the file to deploy
Car.CarInfo();
string file = "testFile1.txt";
// Check if the created file exists in the deployment directory
Assert.IsTrue(File.Exists(file), "deployment failed: " + file +
" did not get deployed");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2392 次 |
| 最近记录: |