简体   繁体   English

Visual Studio 2015(C ++):在第一个构建错误(不是第一个项目)上停止编译

[英]Visual Studio 2015 (C++) : Stop compile on first build error (not first project)

How to stop the compilation of Visual Studio 2015 when it detects compile error? 如何在检测到编译错误时停止Visual Studio 2015的编译?

I mean first build error (may be first .cpp ), not first project because it takes too much time. 我的意思是第一个构建错误 (可能是第一个.cpp ),而不是第一个项目,因为它需要太多时间。
(I have only 1 project.) (我只有一个项目。)

An extension named " StopOnFirstBuildError " is not an answer, 名为StopOnFirstBuildError的扩展名不是答案,
because it stop on first project that has error. 因为它停在第一个有错误的项目上。

Question

(more elaborate) (更详细)

When I pressed F5 or Ctrl+Shift+B , the compiler would compile all (or some) files. 当我按下F5Ctrl + Shift + B时 ,编译器将编译所有(或某些)文件。
In my case, it can detect some errors using only 5 seconds, so I want it to stop compiling NOW. 在我的情况下,它只使用5秒就可以检测到一些错误,所以我希望它立即停止编译。
However, the VS 2015 become non-responsive. 但是,VS 2015变得没有响应。
It also has strong resistance against Ctrl+Break . 它对Ctrl + Break也有很强的抵抗力。
It takes about 30 seconds before I can navigate to the location of error. 我需要大约30秒才能导航到错误位置。
How can I stop the compile-process on the first compile error automatically? 如何自动停止第一次编译错误的编译过程?

History 历史

There is an old thread asked about this for Visual Studio 2008. 一个旧的线程询问Visual Studio 2008。
Its most accepted solution is to go to :- 其最受欢迎的解决方案是: -

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

and paste a certain piece of code . 并粘贴一段代码

However, macro is not supported anymore in VS 2012 . 但是, VS 2012中不再支持宏
(I tried to press Alt+F11 in VS 2015, no macro editor / menu appear.) (我试图在VS 2015中按Alt + F11 ,不显示宏编辑器/菜单。)

The claim is consistent with a question for VS 2010 stated that the above trick is not work. 该声明与VS 2010的问题一致,表明上述技巧不起作用。

The solution for the VS2010 question is to install an extension named " CancelFailedBuild " . VS2010问题的解决方案是安装名为CancelFailedBuild的扩展。

Thus, I downloaded it. 因此,我下载了它。
When executed .vsix (the installer), it said 当执行.vsix (安装程序)时,它说
"This extension is not installable on any currently installed products.". “此扩展程序无法安装在任何当前安装的产品上。”
... it makes sense because the extension said "Works with : Visual Studio 2010, 2012". ...这是有道理的,因为扩展说“与...一起工作:Visual Studio 2010,2012”。

Now I think I am left with a single choice :- 现在我觉得我有一个选择: -
Use macro (the old VS 2008 way) by installing Macros extension . 通过安装宏扩展来使用宏(旧的VS 2008方式)。
(The extension is a result of users' complain about losing the old macro feature .) (该扩展是用户抱怨丢失旧宏功能的结果 。)

Is downloading the extension a good idea? 下载扩展是一个好主意吗?
If so, what is the step after that? 如果是这样,之后的步骤是什么? Is there a code that I should copy-paste? 有没有我应该复制粘贴的代码?
If not, what is the easier way? 如果没有,更简单的方法是什么?

Sorry for posting a lot of hyperlinks. 很抱歉发布了很多超链接。

Workaround 解决方法

Below are the approaches that may alleviate some inconvenience, but do not answer the actual question at all. 以下是可以减轻一些不便的方法,但根本不回答实际问题。

  1. Install a patch that make Visual Studio responsive , so Ctrl+Break works. 安装使Visual Studio响应的修补程序 ,因此Ctrl + Break可以正常工作。
    It requires me to press keyboard manually. 它需要我手动按键盘。
    It seems to work only for Windows 7. (not tested) 它似乎只适用于Windows 7.(未经测试)

  2. Shorten compile time by creating a simple dummy .cpp , then compiling only that single file . 通过创建一个简单的虚拟.cpp缩短编译时间,然后只编译该单个文件
    It is useful for some cases. 它对某些情况很有用。

The solution for the VS2010 question is to install an extension named "CancelFailedBuild". VS2010问题的解决方案是安装名为“CancelFailedBuild”的扩展。

... ...

This extension is not installable on any currently installed products. 此扩展程序无法安装在任何当前安装的产品上。

...it makes sense because the extension said that "Works with: Visual Studio 2010, 2012." ...这是有道理的,因为扩展名称“使用:Visual Studio 2010,2012”。

Visual Studio 2012 extensions are frequently compatible with VS2013 and VS2015. Visual Studio 2012扩展通常与VS2013和VS2015兼容。 You can update the extension yourself by unzipping the .vsix file (it's just a ZIP archive) and updating its manifest (which is an XML file). 您可以通过解压缩.vsix文件(它只是一个ZIP存档)并更新其清单(这是一个XML文件)来自行更新扩展。

This guide shows you the XML elements to change. 本指南向您展示要更改的XML元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM