In Visual Studio, how can I set the build action for the entire folder?

I have a project in Visual Studio. I need to deploy some third-party files along with my code. Usually I put these files in the "Resources" directory and set the build action for each file to "Content" and "Copy to output directory" "Copy if new."

In any case, I can set these directives at the folder level. In the current project I'm working with, there are dozens of such files and several subfolders. I would like to be able to make the entire directory "Content" and "Copy if new."

+42
visual studio
Jan 13 '10 at 19:25
source share
4 answers

Create a project. Add one file as Content. Unload the project and edit the * proj file manually.

<ItemGroup> <Content Include="myfolder**\*.dll**"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> </ItemGroup> 

And then in the Content-ItemGroup I would replace this file with some MsBuild wildcard expression, * .dll, etc.

+43
Jan 13 '10 at 19:34
source share

If you need to install Build Action for the entire folder, the best option is to simply open the .csproj file and use a regular expression to replace all occurrences from

 <Content .... 

to

 <None ... 

This worked great for me .

+6
May 14 '12 at 6:56 a.m.
source share

I am using Visual Studio 2012, and you can click to select multiple items in Solution Explorer, and then edit each item "Copy to output directory" immediately in the "Properties" window.

Of course, this is not equivalent to the solution you are looking for functionally, but semantically it is. And, hopefully, the next person who stumbles upon this post with the help of a huge fix folder (as with me) should not be immersed in the .csproj file.

Hope this helps!

+4
Jul 28 '15 at 21:00
source share

Edit the * .csproj or .vbproj file

Add this tag

  <ItemGroup> <Folder Include="YOUR_FOLDER_NAME_HERE/"> </ItemGroup 

the final file should look like this:

 <Project> <---some more tags---> <ItemGroup> <Folder Include="YOUR_FOLDER_NAME_HERE\" /> </ItemGroup <---some more tags---> </Project> 
+1
Jun 14 '14 at 17:30
source share



All Articles