2
votes

Hi I need copy folder which contains XML configuration files for IoC in Unit Test Projects to TestResults "output" directory. I use Visual Studio 2010.

Visual Studion solution has this structure:

  • MyProject (Solution)
    • MyProject.Tests (Unit Test Project)
      • CoreSettings (folder which contains XML files, I need copy this folder to MyProject.Tests\bin\debug\TestResults\test_XXX\out)

First I tried edit this two files:

  • Local.testsettings
  • TraceAndTestImpact.testsettings

I opened these two configuration files in VS and:

  • chose Deployment >> Add Directory and added in both configuration files folder CorreSettings.

I ran test but folder CoreSettings was not copy to MyProject.Tests\bin\debug\TestResults\test_XXX\out.

I google it and found this https://stackoverflow.com/a/3588829/1110195.

So I edited these files :

  • Local.testsettings
  • TraceAndTestImpact.testsettings

And added this:

<DeploymentItem filename="MyProject.Tests\CoreSettings\" outputDirectory="CoreSettings\">

But it didn’t help.

I tried used attribute way.

on test class I added.

 [DeploymentItem(@"MyProject.Tests\CoreSettings, @"CoreSettings\")]

But also this way didn’t copy folder CoreSettings to TestRestults\test_XXX\out.

In TestRestults\test_XXX\out I found and DLL’s but not CoreSettings folder.

All XML files in CoreSettings folder has:

  • Build Action: Content
  • Copy to Output Directory: Copy always

What I do bad? Thank you for help.

1

1 Answers

1
votes

I had a similar problem and got the answer from the linked question. I had to change (using your example)

<DeploymentItem filename="MyProject.Tests\CoreSettings\" outputDirectory="CoreSettings\">

to

<DeploymentItem filename="CoreSettings\" outputDirectory="CoreSettings\">