Question

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.)

Was it helpful?

Solution

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...

OTHER TIPS

Adding to the previous answer:

I suggest View.NextError command instead of Edit.GoToNextLocation. Do not get confused by its group (View), it actually GOes TO error location in the editor, like if you double-click error item in the error list.

You can also map it to the keyboard this way:

  • Ctrl+Shift+PgUp = View.GoToPreviousError
  • Ctrl+Shift+PgDn = View.GoToNextError

This will allow you to check for errors (and move between them in editor) even without need of displaying the error window and even without running the build.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top