DeploymentItemAttribute的相对路径根是什么? [英] What is the relative path root of DeploymentItemAttribute?
问题描述
使用 MSTest , DeploymentItemAttribute .
推荐答案
每个
相对路径是相对于
在以下位置找到的RelativePathRoot设置
.testrunconfig文件.
Relative paths are relative to the
RelativePathRoot setting found in the
.testrunconfig file. 默认情况下,该设置为解决方案目录.所以,如果您有这个项目结构 That setting is, by default, the Solution directory. So, if you have this project structure 并且您想要部署 required.xml ,您将要创建类似这样的DeploymentItemAttribute And you want to deploy required.xml, you're going to create a DeploymentItemAttribute like this 似乎文件属性需要设置为"内容"和"始终复制"或如果更新则复制". 此MSDN页面上有高级示例. It seems the file properties need to be set to 'Content' and 'Copy always' or 'Copy if newer'. There are advanced examples on this MSDN page. 这篇关于DeploymentItemAttribute的相对路径根是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
SecretProject\
ComponentA\
ComponentA.Test\
Resources\
required.xml
ComponentA.Test.csproj
Tests.cs
SecretProject.sln
[TestClass]
public class Tests
{
[TestMethod]
[DeploymentItem("ComponentA.Test\Resources\required.xml")]
public void Test()
{
}
}