开发者

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

开发者 https://www.devze.com 2023-01-11 01:01 出处:网络
I\'ve got a solution 开发者_如何学Pythonwith 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 f

I've got a solution 开发者_如何学Pythonwith 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.

The edits for #2 could themselves be automated.

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.

For example, in all your projects use this (as last line before the end tag):

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

And in mydefaults.targets, for example:

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


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. I searched for the xml tag, and replaced it carefully with my new desired directory. 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号