5

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.

[DeploymentItem(@"C:\Dir1\Dir2\TestData\addresses.xml", " TestData")]
musium
  • 2,942
  • 3
  • 34
  • 67
  • There's quite a definitive checklist of gotchas for VS 2010 [here](http://stackoverflow.com/questions/883270/problems-with-deploymentitem-attribute). See if that helps? – StuartLC Jan 24 '13 at 12:21

1 Answers1

7

Current folder for DeploymentItemAttribute defaults to output bin folder. So you have to specify first parameter relative to that bin folder:

[DeploymentItem(@"..\..\..\TestData\addresses.xml", " TestData")]
Anri
  • 6,175
  • 3
  • 37
  • 61