如何让 Visual Studio 自动转到构建中的第一个错误?

发布于 2024-08-27 05:42:29 字数 85 浏览 5 评论 0原文

这是通过转到“错误列表”输出窗口并双击第一个错误或按 F8 手动完成的。有没有办法自动执行此操作?

(如果重要的话,我正在使用 C++。)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世界等同你 2024-09-03 05:42:29

vittore 正在步入正轨...

在 VS 中按 Alt+F11 打开宏 IDE。在“MyMacros”下打开“EnvironmentEvents”模块,并在这三行下方

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

粘贴此子:

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

显然,您可以注释掉或删除蜂鸣声和消息框...

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

送你一个梦 2024-09-03 05:42:29

添加到之前的答案:

我建议使用View.NextError命令而不是Edit.GoToNextLocation。不要被它的组(View)迷惑,它实际上转到编辑器中的错误位置,就像双击错误列表中的错误项一样。

您还可以通过以下方式将其映射到键盘:

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

这将允许您检查错误(并在编辑器中在错误之间移动) )甚至不需要显示错误窗口,甚至不需要运行构建。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文