views:

159

answers:

1

This is done manually by going to the "Error List" output window and double-clicking on the first error or pressing F8. Is there a way to automate this?

(I'm using C++ if that matters.)

+1  A: 

vittore is on track...

In VS press Alt+F11 to open the Macros IDE. Under 'MyMacros' open 'EnvironmentEvents' module and below these three lines

'Event Sources End
'End of automatically generated code
#End Region

paste this Sub:

Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean)Handles BuildEvents.OnBuildProjConfigDone
    If Success = False Then
        DTE.ExecuteCommand("Build.Cancel")
        Beep()
        System.Windows.Forms.MessageBox.Show("Build failed!", "Build Events", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error)
        DTE.ExecuteCommand("Edit.GoToNextLocation")
    End If
End Sub

Obviously, you can comment out or delete the Beep and the message box...

kzen
Thanks, the "DTE.ExecuteCommand("Edit.GoToNextLocation")" line was what I was looking for. However this doesn't necessarily go to the first error - any idea how to prevent this event from being called more than once per build?
Jon
Found another post here at SO (http://stackoverflow.com/questions/134796/how-to-automatically-stop-visual-c-build-at-first-compile-error) where they used OutputWindowEvents_OnPaneUpdated event instead...
kzen
Yes I'm using that technique (by Eric Muyser) to cancel the build. But it still has the same issue of being called more than once.
Jon