简体   繁体   English

vs2012中的DeploymentItem不复制文件

[英]DeploymentItem in vs2012 Doesn’t copy files

I want to add a deployment item to my test. 我想在测试中添加部署项。

My solution structure looks like: 我的解决方案结构如下:

MySolution\
-- TestData\
  --addresses.xml
-- ProjectName.TestProject\
  --Internal\
    --MyTestClass.cs 

I've tried to add the file with the following attribute: 我尝试使用以下属性添加文件:

[DeploymentItem(@"TestData\addresses.xml", " TestData")]

…what does not work But if I specify the absuluten file path, vs will copy the file. ...什么不起作用但如果我指定absuluten文件路径,vs将复制该文件。

[DeploymentItem(@"C:\Dir1\Dir2\TestData\addresses.xml", " TestData")]

Current folder for DeploymentItemAttribute defaults to output bin folder. DeploymentItemAttribute当前文件夹默认为输出bin文件夹。 So you have to specify first parameter relative to that bin folder: 所以你必须指定相对于该bin文件夹的第一个参数:

[DeploymentItem(@"..\..\..\TestData\addresses.xml", " TestData")]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM