Parallel MSBuild


Did you know MSBuild can now run your build using all the cores on your proccessor? So if your development machine has multi-cores, and your solution is fairly large (perhaps more than 15 projects, but it varies), and you’re developing in .NET Framework 3.5 or higher, you should give parallel builds a go, and see if there’s any savings in compile time.

Scott Hanselman has 2 great articles on this. He explains how to incorporate parallel builds into Visual Studio, and also talks about how to run parallel build in your build process and scripts.

Take note that it’s not a guarantee that it is always going to make your solution build faster, it also depends on your machine specifications as well as how your project dependency structure. If that structures is linear rather than a tree structure, there would not be much benefit running parallel builds. Also take care about how your project references are used, because running parallel build might cause some unexpected locking problems.

On a more positive note, I’m working on a solution with around 57 projects, and using an 8 core PC. Running parallel build, it shaved off 25 seconds off the usual 2 minutes build. For argument’s sake, if I build my solution say 50 times a time (which is a very optimistic value in my opinion),  I save about  20 minutes a day from compiling (assuming you have an 8 hour work day). That’s a big savings, and that benefit grows over the weeks and months for every developer on your team. Don’t forget your build scripts and automated builds too!