简体   繁体   English

如何在VS解决方案中更改所有构建目录?

[英]How do I change all the build directories in my VS solution?

I've got a solution with dozens of projects. 我有数十个项目的解决方案。 I can individually go into the nice "Properties" tab and change the output directories there, but that would take ages. 我可以单独进入漂亮的“属性”选项卡并在那里更改输出目录,但这会花费很多时间。 What's the fast way? 快速的方法是什么?

Also, there are some old build configurations that are no longer required. 另外,有些旧的构建配置不再需要。 How do I zap them? 我该怎么打呢?

there are some old build configurations that are no longer required. 有些旧的构建配置不再需要。 How do I zap them? 我该怎么打呢?

Some things can be done in Solution Properties | 可以在“解决方案属性”中执行某些操作。 Configuration Manager 配置管理器

But largely you need to modify each individual project. 但是在很大程度上,您需要修改每个单独的项目。

I can individually go into the nice "Properties" tab and change the output directories there, but that would take ages. 我可以单独进入漂亮的“属性”选项卡并在那里更改输出目录,但这会花费很多时间。 What's the fast way? 快速的方法是什么?

  1. A macro? 宏?
  2. The project files ( .csproj , .fsproj , ... depending on the underlying project type) are XML and can be edited inside VS (unload the project, then right click to directly edit the project file) or outside of VS. 项目文件( .csproj.fsproj ,...,取决于基础项目类型)是XML,可以在VS内部(卸载项目,然后右键单击以直接编辑项目文件)或在VS外部进行编辑。

The edits for #2 could themselves be automated. #2的编辑本身可以自动进行。

How much automation you choose really depends on how many projects you have now, and whether you expect to need to make such a bulk change again. 您选择的自动化程度实际上取决于您现在拥有多少个项目,以及您是否期望再次进行如此大的更改。

Remember to keep plenty of backups, it is easy to break things. 记住要保留大量备份,这很容易造成问题。

to change common properties for all your projects at once, you could import a common project in all of them. 要一次更改所有项目的公共属性,可以在所有项目中导入一个公共项目。 Yes, this requires editing all your current projects (although it's not that hard to write a script listing all .csproj/... files recusrively and adding/removing a couple of lines), but if you have to make changes again in the future it will make things a lot easier. 是的,这需要编辑您当前的所有项目(尽管编写一个脚本来列出所有.csproj / ...文件并重新添加/删除几行并不难,但是如果将来您必须再次进行更改,它将使事情变得容易得多。

For example, in all your projects use this (as last line before the end tag): 例如,在所有项目中都使用此代码(作为end标签之前的最后一行):

<Import Project="..\templates\mydefaults.targets/>

And in mydefaults.targets, for example: 在mydefaults.targets中,例如:

<Import Project="mypaths.targets"/>
<PropertyGroup>
  <OutputPath>$(MyCommonBinDir)\(Configuration)$(PlatForm)\</OutputPath>
  <BaseIntermediateOutputPath>$(MyTempDir)\$(AssemblyName)\</BaseIntermediateOutputPath>
</PropertyGroup>

I like to keep the mypaths.target seperate: it defines MyCommonBinDir and MyTempDir, so if I want to build a branch of my original source tree I only have to change that file to set the output paths for all projects at once. 我喜欢将mypaths.target保持分开:它定义了MyCommonBinDir和MyTempDir,因此,如果要构建原始源代码树的分支,只需更改该文件即可一次设置所有项目的输出路径。

Right, I had a look around, and here's what I did: 是的,我环顾四周,这是我做的:

Having nothing loaded, you can go to Edit > Replace in Files. 没有加载任何内容,您可以转到“编辑”>“在文件中替换”。

This allows you to search the solution directory for just .csproj files. 这使您可以在解决方案目录中仅搜索.csproj文件。 I searched for the xml tag, and replaced it carefully with my new desired directory. 我搜索了xml标记,并用新的所需目录小心地替换了它。 Remember to do this for debug and release. 记住要进行调试和发布。 Also, if you're in version control, make sure you don't screw up the base-copy files. 另外,如果您使用的是版本控制,请确保不要破坏基础副本文件。 (That's why you only search for .csproj). (这就是为什么您仅搜索.csproj的原因)。

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

相关问题 如何彻底清理我的VS 2012解决方案? - How can I do a complete clean of my VS 2012 solution? 如何在Visual Studio解决方案中找到所有名称空间? - How do I find all namespaces in my Visual Studio solution? 在VS2010中构建解决方案时,如何仅自动编译已更改的项目? - How can I automaticly compile only projects that have changed when I build my solution in VS2010? 即使某些项目没有任何变化,我如何才能使VS 2015 RC完全构建我的解决方案? - How can I get VS 2015 RC to build my solution entirely even if nothing has changed in some projects? 如何在无序列表中列出所有目录和子目录 - How do i list all directories and subdirectories in an unordered list 如何查看 VS C# .NET 6 项目的所有构建宏值? - How do I view all Build macro values for a VS C# .NET 6 project? 如何从PowerShell构建VS解决方案文件夹 - How to build VS solution folder from powershell 我可以在VS12 / 10中同时更改所有解决方案的项目输出路径吗? - Can I change all solution's projects output paths simultaneously in VS12/10? 如何为解决方案中的所有项目引用一次程序集 - How do I reference an assembly once for all projects in a solution 我的解决方案中出现奇怪的VS2010构建故障 - Strange VS2010 build glitch occurs in my solution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM