Change the property of entire files in a folder in a Visual Studio 2008 project

I added the folder to the visual studio 2008 project by dragging it from the browser. I want to change the copy to output directory property for all files in this Copy Always folder.

The problem is that the folder contains many subfolders as well as subfolders ... so it was a little annoying not to lock all files and change the property in one step.

Is there a way to change the property of all files in a folder containing many subfolders in one procedure?

Many thanks...

+7
source share
3 answers

If you really have a lot of subfolders and files, you can try the following steps.

  • Create an empty project, add your folder to the project
  • Save the project and open the project file in a good text editor
  • This project file will now have all the files for which you want to change the build action.
  • Remove all tags other than content tags (they apply to your files).
  • Simple search and replace for replacing //>/n (slash and corner bracket followed by a new line) using ">/n<CopyToOutputDirectory>Always<//CopyToOutputDirectory>/n<//Content>" . (note that I am using notepad ++ and therefore escaped with a slash). You can always leave new lines if your tool does not support it. You can even try to find and replace regex if your tool supports it.
  • You may need to adjust the file path (if your new project has a different folder hierarchy) - this can be achieved by finding and replacing Include=" .
  • Paste these content nodes into the project file that you want to modify
+3
source

Just open all the folders. Select all the files at once and change the build action to Always Copy. You can select the top item, hold shift, select the last item and select all items.

+4
source

The only way I know is to edit the csproj file. You can create a utility to help you do this.

A quick test showed the following.

 <Content Include="Test.css" /> 

After changing the properties ...

 <Content Include="Test.css"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </Content> 
+1
source

All Articles