Using MSBuild

1 minute read

Building MSBuild projects in parallel

CloudBees Build Acceleration cannot parallelize MSBuild project files. If you have multiple MSBuild projects, however, you can create a makefile to build them in parallel.

MSBuild is best used for multiple projects. For a single project, CloudBees recommends that you use the ecmsbuild.exe wrapper. For details, see <a id="annotation-001"></a> Building Visual Studio Solutions from the Command Line - Using the ecmsbuild.exe Wrapper with Electrify.

For example:

all: project1 project2 project1 msbuild myproject.csproj /t:build project2: msbuild myproject.csproj /t:build

Then run:

emake –f makefile –-emake-emulation=nmake –-emake-cm<your cm>

For C++ projects, call devenv (or ecdevenv) to parallelize those projects down to the project item level.

If you use a top-level MSBuild script that builds separate projects, convert that to NMAKE in the format above to achieve parallelization under eMake.

Alternatively, you can use Electrify on the top-level MSBuild project file.

Using MSBuild to build a project directly in its solution context

When set to true, the ECADDIN_USE_SOLUTION_IN_MSBUILD environment variable lets you use MSBuild to build a project directly, but in the context of its solution, by generating an appropriate call to be sent to MSBuild. For example, when you build a C# project named WindowsApplication2 with project configuration Debug|AnyCPU, the generated makefile contains the following call to MSBuild:

"msbuild.exe" "WindowsApplication2.csproj" /t:build /p:Configuration="Debug",Platform="AnyCPU"

(Note that MSBuild expects there to be no space between Any and CPU.)

When you set the environment variable to true, the command is changed to build the WindowsApplication2 project in solution configuration Debug|Mixed Platforms:

"msbuild.exe" "solution_0012.sln" /t:WindowsApplication2 /p:Configuration="Debug",Platform="Mixed Platforms"