问题描述
{}咆哮的首先,我想说,这不是重复。我问这个问题,previously但它得到闭合为重复时,它不是。 :此问题是特定于VS 2010 和答案在VS 2008中所谓的重复工作,但不是在VS 2010中(至少不是我或我认识的人)。让你去收东西是重复你怎么样的阅读前的问题仔细的尝试的为自己的答案,看看它的实际工作。道歉的言论,但也没有明显的方式联系SO警方关闭了该问题或得到它重新打开。 {/咆哮}
{rant}First I'd like to say that this IS NOT A DUPLICATE. I've asked this question previously but it got closed as a duplicate when it isn't. This question is SPECIFIC to VS 2010 and the answers to the so-called duplicate work in VS 2008 but not in VS 2010 (at least not for me or anyone I know). So before you go closing something as a duplicate how about you read the question carefully and try the answer for yourself and see if it actually works. Apologies for the rant but there is no obvious way to contact the SO police that closed the issue or get it reopened. {/rant}
在工作中,我们有超过80个项目是C#的解决方案。在VS 2008中,我们使用宏来尽快停止编译的解决方案中的一个项目构建失败,(看到这个问题的几个选项VS 2005和放大器; VS 2008:http://stackoverflow.com/questions/134796/how-to-automatically-stop-visual-c-build-at-first-compile-error).
At work we have a C# solution with over 80 projects. In VS 2008 we use a macro to stop the compile as soon as a project in the solution fails to build (see this question for several options for VS 2005 & VS 2008: http://stackoverflow.com/questions/134796/how-to-automatically-stop-visual-c-build-at-first-compile-error).
是否有可能在VS 2010中做的一样吗?我们发现的是,在VS 2010中的宏不工作(至少我不能让他们的工作),因为它看来,环境事件不会在VS 2010中闪光。
Is it possible to do the same in VS 2010? What we have found is that in VS 2010 the macros don't work (at least I couldn't get them to work) as it appears that the environment events don't fire in VS 2010.
默认行为是继续尽可能地,并在错误窗口中显示错误的列表。我很高兴它作为一个项目不能建设(项目级)。
The default behaviour is to continue as far as possible and display a list of errors in the error window. I'm happy for it to stop either as soon as an error is encountered (file-level) or as soon as a project fails to build (project-level).
解答了VS 2010只请。如果宏不工作,那么如何配置它们的VS 2010将AP preciated一个详细的解释。
Answers for VS 2010 only please. If the macros do work then a detailed explanation of how to configure them for VS 2010 would be appreciated.
感谢。
推荐答案
(您现在可以download这是一个扩展的,如果你不希望建立自己动手)
(You can now download this as an extension, if you don't want to build it yourself)
这答案只有在VS2010工程(似乎是公平的:])。我已经把在我的github上页源了。在可以构建它,你需要<一个href="http://www.microsoft.com/downloads/details.aspx?FamilyID=47305cf4-2bea-43c0-91cd-1b853602dcc5&displaylang=en">install该SDK 。一旦你做到了这一点,就抓住从GitHub上(包括项目文件)的完整源代码和构建。您可以通过查找VSIX在构建输出,并打开它安装输出到您的正常VS实例。
This answer only works in VS2010 (seems fair :]). I've put the source up on my github page. Before you can build it, you'll need to install the SDK. Once you've done that, just grab the complete source from github (includes project files) and build that. You can install the output into your normal VS instances by finding the VSIX in your build output and opening it.
最重要的部分是:
public void TextViewCreated(IWpfTextView textView)
{
var dte = GlobalServiceProvider.GetService(typeof(DTE)) as DTE;
textView.TextBuffer.Changed += (sender, args) =>
{
//Output window is friendly and writes full lines at a time, so we only need to look at the changed text.
foreach (var change in args.Changes)
{
string text = args.After.GetText(change.NewSpan);
if (BuildError.IsMatch(text))
dte.ExecuteCommand("Build.Cancel");
};
}
}
...其中, BuildError
是上面,你可以调整定义的正则表达式。如果您有关于修改code有任何疑问,请让我知道。
... where BuildError
is a regex defined above that you can tweak. If you have any questions about modifying the code, let me know.
这篇关于VS2010 - 如何自动停止编译第一次编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!