Deployment folder won't get copied.

In my test project I have a folder with a few xml files which I set the properties to be content/copy always. I added this folder to the additional files and directories to deploy window in my .testrunconfig file. When I run my test, all xml files are copied to the out directory but not the folder. So it basically flattens the directory structure on deployment. How do I tell it to preserve the directory structure

Thanks.



Answer this question

Deployment folder won't get copied.

  • Tumbalam

    Thanks Kevin. Using the attribute works for me.
  • vsnewbie

    So what you are saying is there isn't a way to tell it to maintain the directory structure when I run the tests I think this is a big limitation. It requires code change when I want to do tests because my code is expecting these files to be inside a folder. Isn't the point of Unit Testing is to test your existing code and not have to change it


  • crhill1979

    Great! This is apparently the only option to solve the same problem with generic tests.


  • Muralidharan

    The directory structure is maintained beneath the directory that was selected for deployment. However, the selected directory itself is not created in the deployment directory.

    Thanks,

    Rick


  • Hadrienlc

    You can specify output directory for deployment using Run Configuration file:
    - add the directory using Run Config UI
    - in solution explorer right-click on .testrunconfig solution item
    - select Open with...
    - select XML Editor
    - Edit->Advanced->Format Document. This will nicely format the XML.
    - find your deployment item and change the outputDirectory field to be like this:
    <path type="System.String">TestFiles\</path>
    <
    outputDirectory type="System.String">TestFiles</outputDirectory>
    - save the .testrunconfig file

    Yes, we did not do UI for specifying output dir, while you can always do that by manually editing .testrunconfig file. That's limititation of current version.

    Thank you for your feedback,
    Michael Koltachev
    Visual Studio Team System


  • orical23

    One thing you can do is use the DeploymentItem attribute on the test itself, rather than the test run config. This lets you specify an output directory. E.g.:

    [TestMethod]
    [DeploymentItem("XmlFiles", "XmlFiles")]
    public void Test1()
    {
    ...
    

    This will copy the contents of XmlFiles into a directory called XmlFiles under the deployment directory, effectively preserving the directory structure. However, you can only do this with the attribute (which must be added to each test), not the run config file. Another option is to deploy a directory one level up from the one you want, e.g. put XmlFiles in Files and deploy Files, so the deployment directory will contain XmlFiles. This may not work well since you have to change the directory structure.

    I agree that there should be a way to keep files in their directory when deployed from the run config, so I'll file a suggestion internally about this.


  • Deployment folder won't get copied.