DeploymentItemAttribute的相对路径根是什么? [英] What is the relative path root of DeploymentItemAttribute?

查看:120
本文介绍了DeploymentItemAttribute的相对路径根是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 MSTest DeploymentItemAttribute .

推荐答案

每个

相对路径是相对于 在以下位置找到的RelativePathRoot设置 .testrunco​​nfig文件.

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

SecretProject\
    ComponentA\
    ComponentA.Test\
        Resources\
            required.xml
        ComponentA.Test.csproj
        Tests.cs
    SecretProject.sln

并且您想要部署 required.xml ,您将要创建类似这样的DeploymentItemAttribute

And you want to deploy required.xml, you're going to create a DeploymentItemAttribute like this

[TestClass]
public class Tests
{
    [TestMethod]
    [DeploymentItem("ComponentA.Test\Resources\required.xml")]
    public void Test() 
    {

    }
}

似乎文件属性需要设置为"内容"和"始终复制"或如果更新则复制". 此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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆