views:

880

answers:

10

I am currently involved in a ASP.NET project with about 40 projects in the solution. We are doing all our development in cloned Virtual PC environments so all developers have identical setups. That's all good, managing dependencies is easy, however building the solution is horribly slow. Virtual PC can only utilize one CPU so I'm really only using half of my computers resources.

It takes a full 3 minutes from build to a complete page load.. and it's getting worse every day as the projects grow. Fixing simple things is starting to take a long time and personally, I'm getting frustrated waiting all the time as I can't really work while the computer is compiling.

Is there any way of distributing my build across several computers to speed up the build process?

Would an SSD noticeably improve upon my build times?

Are there any other way of speeding up the build?

Note: I have tried precompiling static dependencies with ngen but later read that ASP.NET does not support ngen. I use Visual Studio 2008 and there is no antivirus software present in the virtual environment.

+2  A: 

Do you need to rebuild all 40 projects every time.

You can configure what gets built in the Solution Configuration settings.

I.e. if you're changes are only in your WebUI Project, and the other 39 projects are unchanged, you can create a build configuration where only your web application is rebuilt.

  • Look at the Configuration Drop Down
  • Click "Configuration Manager"
  • In the "Active Solution Configuration" drop down click "New"
  • Create a new Config copied from the Debug Configuration
  • In your new Configuration, uncheck all project builds except the ones you've made changes in
Eoin Campbell
If there aren't any changes in the lower projects though, msbuild is clever enough to realise that nothing has changed and doesn't rebuild them.When you make a change to a file to be recompiled, it will recompile itself and all of it's dependencies.
Matthew Steeples
But then how do I know I don't break the build in those projects I don't build?
weazl
You only build projects "Above" the project you made changes to in your dependency chain...If you have 39 DLL projects, that are referenced in your Web App, and you only change your web app, then the changes won't break anything downwards.
Eoin Campbell
I commonly make changes in multiple layers as this project is in active development, reconfiguring the build configuration every time I'm about to make a change in a lower level seems like asking for trouble.
weazl
A: 

You didn't mention your Visual Studio version, but if it's 2005 you might want to consider an upgrade to 2008. In my case this decreased build time on a largish (30+ projects) solution.

Another option it to pre-build a number of libraries that do not change anymore and reference the compiled dll's in stead of the projects.

edosoft
I use VS 2008. Prebuilding doesn't really help all that much since the only projects we don't change anymore are small and probably builds pretty fast anyway.
weazl
A: 

We have a similar situation, and I found that our virtual machines were being heavily throttled, and so although they each ran on a single CPU, they weren't allowed to fully utilise that CPU. I managed to get 3 virtuals running on one physical to all perform 100% faster.


I'd also look at trying to reduce your number of projects. Our main solutions has 40 projefts, and I've been slowly consolidating these, and making sure new development fits in to existing projects where possible. The main culprits for this were webservices, where each had originally been created in a separate project. I am now adding all new webservices into a single project, and slowly moving the others across.

ck
+1  A: 

Scott Gu has an fairly helpful post about this:

Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005

Scott also has another article on the speed of this Hard Disk, which also has an impact on the general performance of Visual Studio:

Tip/Trick: Hard Drive Speed and Visual Studio Performance

CraigTP
Another one to watch-out for is anti-virus being set-up to scan files on read/write. I find it advantageous to exclude my working folder(s) from AV on-access scanning.
Paul Suart
@thedorko - I agree, and Scott Gu does address this (amongst other things) in the first article that I linked to.
CraigTP
Ah, fair enough. My bad for not reading the article!
Paul Suart
A: 

Have you tried tuning up virtual PC?

http://www.windowsnetworking.com/articles_tutorials/Tuning-Virtual-PC-Performance.html

Old article but the gist is still correct.

I found, in a similar situation, that having a separate hard disk for the VPC disk images sped up performance remarkably especially when removing some of the throttling.

Maybe the problem isn't Visual Studio, it's just the fact that compilation is resource intensive.

DavidWhitney
The image is run from a separate defragmented drive and I have a dual core system. When compiling the single virtual CPU hits 100% usage pretty much through the entire build process.. not the harddrive.
weazl
When you say "single virtual CPU" do you mean the CPU inside the virtual machine or the single core on the parent machine?
DavidWhitney
Oh, sorry, poor wording there perhaps. I meant the CPU inside the virtual machine.
weazl
There's a chance that in VPC configuration you haven't allowed it to utilise all of the CPU?Past that, perhaps consider testing against VMware and VirtualBox, they can all mount the drive images of the other virtualisation platforms so it's worth looking in to. VmWare certainly lets you use more than one core, and is equally free.
DavidWhitney
A: 

You might also consider switching to VMware Workstation, which does utilize multiple processors. I'm currently using a setup with two two-processor VMs, and all four do get used.

John Saunders
+1  A: 

Do not put so many projects in your solutions. Only create a new project when the code is run in a different process or on a different machine. There is no use to create so many projects in most cases. The number of projects is the most significant slow down in msbuild.

Paco
True, that does seem relevant. I might try to reduce the number of projects if I get the time, however I doubt management would like that. This is a rather large system with several different components and multiple layers of abstraction.. they can't all be in the same project.
weazl
Are the layers running on several physical tiers?
Paco
You could, however, consolidate groups of projects into relevant solutions. It means you need to switch solutions or use multiple instances of VS from time to time but it's much more manageable.
DavidWhitney
There are a few projects that are run as a separate web service on a different machine, but they are already in a solution of their own. But most of the projects I work on, and some I don't work on, share common lower levels that I modify frequently.. thus I have to build them all to make sure I don't break anything when modifying an interface for instance.
weazl
In that case I would merge the projects where possible. Making 20 or 10 projects instead of 40 will save you more then 50% of the build time.
Paco
A: 

What we did at our company is to use file reference, so only the changed projects need to be built, and at any given time there is no more than 10 projects in my solution, mostly 2~3 gets built.

We also build our trunk for each check-in, and have batch file for developers to pull the most recent dlls.

Of course, this doesn't stop the painful assembly reference error from happening, but they become more of a nuisance than problem after a while.

Bill Yang
+1  A: 

You can greatly reduce the time you wait for a build with ASP.NET by doing the following:

  • Use the new "optimizeCompilations" flag. It will tell .NET to not rebuild the entire project just because you changed one project/dll. If you have 40 projects and you don't use this, every time you change a simple method in one project, .NET will try to compile all other projects and dlls. With the new flag (plus the installation of a hotfix) you will see a lot of increase overall performance during development. Check it out this blog post with details on how to speed up the build with this the optimizeCompilations flag: http://www.wagnerdanda.me/2009/11/optimizing-asp-net-build-time-with-dynamic-compilation-and-optimizecompilations/

Hope it helps!

Wagner Danda da Silva

Wagner Danda da Silva
Why is this not on by default? It seems to be doing wonders on some projects..
weazl
Starting with Windows 7 you won't need to install the hotfix in order to use the 'optimizeCompilations' flag. The same will be available with .NET Framework 4.0. However, using this flag is an aggressive option that should be carefully considered. It is helpful in most cases, but it has some disadvantages. See this post http://msdn.microsoft.com/en-us/library/ms366723.aspx (section "Disadvantages of Dynamic Compilation") to understand.
Wagner Danda da Silva
+1  A: 

And here is another tip to speed up build times with ASP.NET:

Hope it helps!

Wagner Danda da Silva

Wagner Danda da Silva