简体   繁体   English

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

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

I was adding a folder to my visual studio 2008 project, by dragging and dropping from explorer. 我通过从资源管理器中拖放来为我的visual studio 2008项目添加一个文件夹。 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... 非常感谢...

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,选择最后一项,然后选择所有项目。

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>" . 使用">/n<CopyToOutputDirectory>Always<//CopyToOutputDirectory>/n<//Content>"简单查找和替换以替换//>/n (斜线和斜角括号后跟新行)。 (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=" . 您可能必须调整文件路径(如果您的新项目具有不同的文件夹层次结构) - 这可以通过查找和替换Include="来实现。
  7. Paste these content nodes into the project file that you want to modify 将这些内容节点粘贴到要修改的项目文件中

Only way I know is to edit the csproj file. 我只知道编辑csproj文件。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Visual Studio 2008 中将项目更改为 Web 应用程序 - Change project to Web Application in Visual Studio 2008 在Visual Studio模板中更改项目文件夹路径 - Change Project Folder Path in Visual Studio Template Visual Studio 2008安装项目 - Visual Studio 2008 Setup Project 构建时,将项目的全部内容复制到另一个项目的文件夹中(Visual Studio 2013) - Copy the entire contents of a project in a folder of another project, when build (Visual Studio 2013) Visual Studio中缺少文件夹和文件。 甚至不在项目中显示 - Missing folder and files from visual studio. not even showing in Project 如何将Visual Studio 2013项目降级为Visual Studio 2008项目? - How to downgrade a Visual Studio 2013 project to a Visual Studio 2008 project? Visual Studio 2008文件夹浏览器对话框 - Visual Studio 2008 folder browser dialog 在Visual Studio中更改项目中所有图像的“构建操作”属性? - Change 'Build Action' property for all images in a project in Visual Studio? 使用EnvDTE以编程方式更改Visual Studio项目的Debug属性 - Change Debug property of a Visual Studio project programmatically using EnvDTE 如何打开“测试项目”代码文件夹中的文件? (Visual Studio 2008和.NET C#) - How to open a file inside a Test Project code folder? (Visual Studio 2008 and .NET C#)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM