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

和自甴很熟 提交于 2019-12-23 09:23:26

问题


I was adding a folder to my visual studio 2008 project, by dragging and dropping from explorer. I want to change the 'copy to output directory' property of the entire files in that folder to 'Copy Always'.

The problem is that the folder contains many subfolders, and so does the subfolders..so it was a little bit annoying not to be able to block all files and change the property in one step.

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

Many Thanks...


回答1:


If you really have a lot of sub-folder & files then you can try these steps

  1. Create am empty project, add your folder to the project
  2. Save the project and open the project file in a good text editor
  3. This project file will now have all files for which you want to change the build action
  4. Remove all other tags other than content tags (these refer to your files)
  5. Do simple find & replace to replace //>/n (slash & angled bracket followed by new line) with ">/n<CopyToOutputDirectory>Always<//CopyToOutputDirectory>/n<//Content>". (note that I use notepad++ and hence have escaped slashes). You can always leave out new lines if your tool doesn't support it. You may even try regex find & replace if your tool supports it.
  6. You may have to adjust file path (if your new project has different folder hierarchy) - this can be achieved by find & replace Include=".
  7. Paste these content nodes into the project file that you want to modify



回答2:


Just expand all the folders. Select all the files at once, and change the Build Action to "Copy Always". You can select the top item, hold shift, select the last item and that will select all items.




回答3:


Only way I know is to edit the csproj file. You could create a utility to help you do this.

A quick test i did yielded the following.

<Content Include="Test.css" />

After changing the properties...

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


来源:https://stackoverflow.com/questions/8251909/change-the-property-of-entire-files-in-folder-in-visual-studio-2008-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!