Wednesday, May 18, 2011

Speed up Visual Studio Builds

Recently I got involved in a big project where we had a single solution with approximately 100 projects.
Why 100 Projects in a Solution?

The reason for a 100 projects solution is that like in many modular systems these days, we have the following three tiers:

A few core / common projects every project will use.
A large amount of modules, independent of each other. This tier directly depends on tier 1.
A few end-projects which loads the different modules. This tier indirectly depends on tier 2.

So, yes, we could create several solutions with each tier compiling only when needed and using DLL reference instead of project references, but the amount of changes in all the tiers was still large enough and I’ve already seen this kind of build process fail miserably. So this was no go.
Build time took 15 minutes for the whole solution. Since we enforced a gated check-in policy in the company, this was really a pain point for the developers. Note that the developers’ computers were strong enough, with 8GB ram, Intel Core i7 CPU and SSD disks. So I’ve started investigating what can be done to improve the situation.

Step 1: Build Projects in Parallel

Although the PC has 8 logical cores, the build system in Visual Studio 2010, when using C#, still uses only a single core! (Note this is not the case in C++ build system). So after browsing the web, I’ve found how you can manually trigger msbuild yourself as a Visual Studio external tool to compile your solution in parallel.
image_thumb_078CB77E.png