MSBuild is introducing a new feature in Orcas where projects can be built in parallel – see their team blog post for details. Team Build has added support for this feature by:
- Modifying Microsoft.TeamFoundation.Build.targets to build each configuration in parallel if possible,
<MSBuild BuildInParallel="true" Projects="@(ConfigurationList)" Targets="CompileConfiguration" StopOnFirstFailure="$(StopOnFirstFailure)"> <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" /> </MSBuild>
- Modifying Microsoft.TeamFoundation.Build.targets to build each solution in parallel if possible, and
<MSBuild BuildInParallel="true" Projects="@(SolutionList)" Targets="CompileSolution" StopOnFirstFailure="$(StopOnFirstFailure)"> <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" /> </MSBuild>
- Adding a MaxProcesses key to TfsBuildService.exe.config (typically installed to %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies) that allows you to specify, for a given build machine, how many processes should be used when msbuild.exe is invoked.
<!-- MaxProcesses Set this value to the maximum number of processes MSBuild.exe should use for builds started by agents hosted by this executable. --> <add key="MaxProcesses" value="1" />
By default, the MaxProcesses key is set to one, meaning that only a single process will be used for builds and no parallelization (is that actually a word?) will occur. To use more than one process, set the key to your desired value and restart the team build service (“net stop vstfbuild” and then “net start vstfbuild” for you command-line people). At this point, the magic will kick in and (hopefully) your builds will speed up quite a bit.
There are some caveats here – MSBuild can manage your intra-solution dependencies (assuming you have used project references) to make sure to only build things in parallel which can be built in parallel. If you have build order dependencies that are not specified via project references (e.g. inter-solution dependencies and/or file references) you should stick to a single process.