在Visual Studio 2008项目中更改文件夹中整个文件的属性

时间:2023-01-15 00:12:07

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'.

我通过拖放浏览器向我的visual studio 2008项目添加了一个文件夹。我想将该文件夹中整个文件的“复制到输出目录”属性更改为“始终复制”。

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...

3 个解决方案

#1


3  

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. 创建一个空项目,将您的文件夹添加到项目中

  3. Save the project and open the project file in a good text editor
  4. 保存项目并在优秀的文本编辑器中打开项目文件

  5. This project file will now have all files for which you want to change the build action
  6. 此项目文件现在将包含您要更改构建操作的所有文件

  7. Remove all other tags other than content tags (these refer to your files)
  8. 删除内容标记以外的所有其他标记(这些标记指的是您的文件)

  9. 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.
  10. 使用“> / n Always / n ”进行简单查找和替换以替换//> / n(斜线和斜角括号后跟新行)。 (注意我使用记事本++,因此有转义斜杠)。如果您的工具不支持,您可以随时省略新行。如果您的工具支持,您甚至可以尝试使用正则表达式查找和替换。

  11. You may have to adjust file path (if your new project has different folder hierarchy) - this can be achieved by find & replace Include=".
  12. 您可能必须调整文件路径(如果您的新项目具有不同的文件夹层次结构) - 这可以通过查找和替换Include =“来实现。

  13. Paste these content nodes into the project file that you want to modify
  14. 将这些内容节点粘贴到要修改的项目文件中

#2


4  

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.

只需展开所有文件夹即可。一次选择所有文件,并将构建操作更改为“始终复制”。您可以选择顶部项目,按住shift,选择最后一项,然后选择所有项目。

#3


1  

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

我只知道编辑csproj文件。您可以创建一个实用程序来帮助您执行此操作。

A quick test i did yielded the following.

我做了一个快速测试,结果如下。

<Content Include="Test.css" />

After changing the properties...

更改属性后......

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

#1


3  

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. 创建一个空项目,将您的文件夹添加到项目中

  3. Save the project and open the project file in a good text editor
  4. 保存项目并在优秀的文本编辑器中打开项目文件

  5. This project file will now have all files for which you want to change the build action
  6. 此项目文件现在将包含您要更改构建操作的所有文件

  7. Remove all other tags other than content tags (these refer to your files)
  8. 删除内容标记以外的所有其他标记(这些标记指的是您的文件)

  9. 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.
  10. 使用“> / n Always / n ”进行简单查找和替换以替换//> / n(斜线和斜角括号后跟新行)。 (注意我使用记事本++,因此有转义斜杠)。如果您的工具不支持,您可以随时省略新行。如果您的工具支持,您甚至可以尝试使用正则表达式查找和替换。

  11. You may have to adjust file path (if your new project has different folder hierarchy) - this can be achieved by find & replace Include=".
  12. 您可能必须调整文件路径(如果您的新项目具有不同的文件夹层次结构) - 这可以通过查找和替换Include =“来实现。

  13. Paste these content nodes into the project file that you want to modify
  14. 将这些内容节点粘贴到要修改的项目文件中

#2


4  

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.

只需展开所有文件夹即可。一次选择所有文件,并将构建操作更改为“始终复制”。您可以选择顶部项目,按住shift,选择最后一项,然后选择所有项目。

#3


1  

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

我只知道编辑csproj文件。您可以创建一个实用程序来帮助您执行此操作。

A quick test i did yielded the following.

我做了一个快速测试,结果如下。

<Content Include="Test.css" />

After changing the properties...

更改属性后......

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