Stopping Visual Studio’s build on first error

Not stopping the build on the first error is a feature that allows you to get more errors in a single build pass and that most younger developers take for granted.

While this is sometimes the best possible behaviour, there are situations where this is not desirable. If you have a large solution with many layered project dependencies and you are working on one of the bottom layer you will eventually end up with loads of cascading “Cannot find referenced assembly” errors. These do not give you any information beside the fact that assembly X did not compile and assembly Y needs assembly X and can’t find it.

Something you already know since you just saw the message when assembly X failed.

One the solutions I am working on is a large solution where compilation is painfully long. Combine this to the fact when pressing Ctr-Break to stop this chain of “Cannot find referenced assembly” I must wait a few seconds for the computer to break out of the resource heavy operation that such a compilation represents and you get a dreary situation.

I had previously tried a macro for this (which you can find many variations online), but my main gripe was that it changed the behaviour of Visual Studio to always stop after the first project had encountered errors. What I wanted was to be able to easily toggle this to reflect my current situation in Visual Studio.

My search for something better lead me to the Visual Studio add-in: StopOnFirstBuildError in Visual Studio’s add-in gallery. You can also read the author’s blog post on the subject: Stop Build on first error in Visual Studio 2010.

Basically the most important feature of this add-in is the ability to easily toggle the Stop build on first error functionality via an item in your build menu.

Now you can have the best of both worlds.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s