I have a solution which contains a lot of C# projects, how can I change the configuration of all projects very quickly, like I want to change the output folder from bin to MyBin. I know C++ property sheet can do the similar thing but C# doesn't have property sheet.
You can use a common 'partial' project file to store common stuff.
Move all the stuff that you want to be changed simultaneously into a stand-alone .proj file, e.g. common.proj
:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputPath>Debug</OutputPath>
<Platform>AnyCPU</Platform>
</PropertyGroup>
</Project>
Than use msbuild import declaration to 'include' common part into every project in your solution:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="common.proj" />
</Project>
MsBuild imports work more or less in the same manner as C++ includes: before a project is built all the import directives are replaced with the content of the imported file. Now you can change your common properties just in one file - common.proj
There's one important thing to mention: VS caches included project files, so you'd have to reload all the projects after applying a change to common.proj
file (so I suggest building from command-line when you actively change commom.proj
)
We use this approach to manage code-analysis settings (as they are supposed to be the same across all the projects in the solution).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With