I\'m trying to edit my project file to enable me to have a project that builds multiple build configs at once. I\'ve done this using a batching approach and using the MSBuil
It is important to realize that when you use a "MSBuild" task, a new child MSBuild process will be started. The implication of this is that any items and properties you define in the parent MSBuild process will not be automatically passed to/visible from the child MSBuild process unless you explicitely pass them via Properties
attribute on MSBuild
element (as in
).
To answer your question, I wrote the following self-contained example that runs a child MSBuild project for all the specified configurations:
First, create a directory for your MSBuild experiment (for example I used C:\temp\msbuildtest
)
In this directory, create the first file, main.proj
:
In the same directory, create the second file, child.proj
(in your case this would be the actual C# project you're trying to build, but because I'm trying to illustrate my point, I am using a simple child project that instead of running C# compiler just prints values of properties :-) )
Now you can run the example. First the default, if you don't explicitly specify configurations to build:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild main.proj
> (cut the noise)
> Build:
> Building configuration Debug with output path C:\temp_c\d\bin\Debug
And then explicitly specified multiple configurations:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild main.proj /property:Config=Debug+Release+Staging+Production
> (cut the noise)
> Build:
> Building configuration Debug with output path C:\temp_c\d\bin\Debug
> Build:
> Building configuration Release with output path C:\temp_c\d\bin\Release
> Build:
> Building configuration Staging with output path C:\temp_c\d\bin\Staging
> Build:
> Building configuration Production with output path C:\temp_c\d\bin\Production
You should be able to adapt this technique to your situation.