Including content files in .csproj that are outside the project cone

前端 未结 7 1754
忘掉有多难
忘掉有多难 2020-11-27 12:09

I have a C# project say MyProject.csproj located at \"C:\\Projects\\MyProject\\\". I also have files that I want copied into the output directory of this project. But, the f

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 12:48

    I believe @Dmytrii gets it right on one hand - you want to use the "link" feature.

    However, he's only partly correct when saying you can't link to a directory tree. While this is, indeed, true when trying to add the links using Visual Studio's GUI, MSBuild supports this.

    If you want to preserve the directory structure, just add the %(RecursiveDir) tag to your node:

    
      %(RecursiveDir)%(Filename)%(Extension)
      PreserveNewest
    
    

    The page MSBuild Well-known Item Metadata goes into more detail on the metadata you can access.

提交回复
热议问题