Take the 2-minute tour ×

I know I can compile individual source files, but sometimes -- say, when editing a header file used by many .cpp files -- multiple source files need to be recompiled. That's what Build is for.

Default behavior of the "Build" command in VC9 (Visual C++ 2008) is to attempt to compile all files that need it. Sometimes this just results in many failed compiles. I usually just watch for errors and hit ctrl-break to stop the build manually.

Is there a way to configure it such the build stops at the very first compile error (not the first failed project build) automatically?

share|improve this question
Dear people from The Future - in VS 2010+, try the StopOnFirstBuildError extension –  brichins Feb 7 '13 at 16:20

5 Answers 5

up vote 24 down vote accepted

I came up with a better macro guys. It stops immediately after the first error/s (soon as build window is updated).

Visual Studio -> Tools -> Macros -> Macro IDE... (or ALT+F11)

Private Sub OutputWindowEvents_OnPaneUpdated(ByVal pPane As OutputWindowPane) Handles OutputWindowEvents.PaneUpdated
    If Not (pPane.Name = "Build") Then Exit Sub

    Dim Context As String = pPane.TextDocument.Selection.Text

    Dim found As Integer = Context.IndexOf(": error ")

    If found > 0 Then
    End If

End Sub

Hope it works out for you guys.

share|improve this answer
@Eric, thanks, this looks like a good solution, I'll give it a try. Anyone know why @Eric's suggestion was down-voted? –  jwfearn Jul 6 '09 at 18:50
According to my reputation page I wasn't down-voted. I dunno. –  Eric Muyser Jul 7 '09 at 12:39
Good effort, and it does work. But it flickers like anything while building, so it's not for me. If only there was a way to get the text from the output window without having to do select all... –  demoncodemonkey Apr 23 '10 at 14:06
You don't need to use select all; you should be able to do something like bool found = pPane.TextDocument.StartPoint.CreateEditPoint().FindPattern(": error"). It should hopefully be quicker, too, since it doesn't rely on copying the entire text of the output window out on every pane update. –  Noah Richards Jun 11 '10 at 2:43
@Noah Richards, Thanks for weighing in! I wasn't able to find that, and so I settled for SA. Next time I fire up VS I'll give it a try and update the answer. –  Eric Muyser Jun 24 '10 at 4:50

I know the question was for VS 2008, but I stumbled across it when searching for the same answer for VS 2012. Since macros are no longer supported in 2012, macro solutions won't work anymore.

You can download an extension that apparently works in VS 2010 and 2012 here. I can confirm that it works well in VS 2012.

The original link to the extension was given in this response.

share|improve this answer

There is this post - not sure if it stops the build at the first error or the first failed project in a solution.

Ctrl-break will also stop it manually.

Now if there was some way to stop it spending 10mins rebuilding intelisense after a build failed!

share|improve this answer
But ctrl-break corrupts the files being created at that time, so you have to recompile them explicitly. –  Lev Sep 26 '08 at 12:02
the method described in the link stops the build at the first PROJECT failure not the first compile error. –  jwfearn Oct 13 '08 at 16:41

Yeah, this works fine on MSVC 2005-2010:

Public Module EnvironmentEvents
  Private Sub OutputWindowEvents_OnPaneUpdated(ByVal pPane As OutputWindowPane) Handles OutputWindowEvents.PaneUpdated
    If Not (pPane.Name = "Build") Then Exit Sub

    Dim foundError As Boolean = pPane.TextDocument.StartPoint.CreateEditPoint().FindPattern(": error")
    Dim foundFatal As Boolean = pPane.TextDocument.StartPoint.CreateEditPoint().FindPattern(": fatal error")

    If foundError Or foundFatal Then
    End If
  End Sub
End Module
share|improve this answer
Worked for me in VS 2008, thanks. One thing I added to open the error list DTE.Windows.Item(EnvDTE80.WindowKinds.vsWindowKindErrorList).Activate() –  Thomas Oct 12 '11 at 17:44

This can be done by adding a macro that is run in response to the event OnBuildProjConfigDone.

The macro is as follows:


  If Success = False Then
  End If

End Sub
share|improve this answer
this method stops the build at the first PROJECT failure not the first compile error. –  jwfearn Oct 13 '08 at 16:47
Yes, but for me that's close enough (as opposed to building the next 20 or so projects before stopping). –  jmatthias Dec 7 '08 at 6:37
I guess it depends on how many files are in a project and what you're compiling. If I change a file included everywhere, it can trigger a fairly long rebuild and if I have a typo, I'd rather have my build stop right away. Perhaps VC10 (with MSBuild) will be able to do what I want. –  jwfearn Dec 27 '08 at 1:55
This isn't what the original poster was looking for, but it's just what I was looking for. In case it's not obvious, you add this by going to Tools->Macros->Macros IDE, open EnvironmentEvents and paste it in there. –  mhenry1384 Jan 13 '09 at 20:05
Thanks, this works very nicely. –  David Schmitt Jan 24 '11 at 7:47

Your Answer


