views:

270

answers:

2

New information:
This question has been re-asked here and has been correctly answered by Noah Richards with a solution that works in VS 2010.

At work we have a C# solution with over 80 projects. Is it possible in VS 2010 to automatically stop compilation as soon as an error is encountered rather than the default behaviour which 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).

I'd also note that in VS 2008 we used macros similar to some of the answers below but they don't work in VS 2010 (at least I couldn't get them to as the environment events don't seem to fire in VS 2010).

Also Somewhat Related:
How to automatically stop Visual C++ build at first compile error?

A: 

Ctrl+Break should do the trick.

cand
this does not answer the question. Ctrl+Break stops the build at any time, not when the first error is encountered.
Sam Holder
So, when it stops at any time, doesn't it stop when first error is encountered?
cand
@cand, no it doesn't. It stops when you press the keys. It does not stop when the first error is encountered, unless you press the keys at the same time.
Sam Holder
Ok, I agree that Your solution is probably better (but I haven't tested it), but in the question there is no clear indication on whether it should be compiler which stops building or any other option. Maybe for the case mentioned by Ben "Ctrl+Break" is enough (at least most of Us accept it as a necessary evil and live with it).
cand
Its not my solution, as I stated its from another question, and anyway it didn't work and I have removed it. It obviously isn't sufficient for Ben, as he asked specifically for a way to automatically stop the build, which this manual method isn't.
Sam Holder
+1  A: 

This question got closed as a duplicate so I re-asked it and it has been correctly answered by Noah Richards.

See this question http://stackoverflow.com/questions/3041982/vs2010-how-to-automatically-stop-compile-on-first-compile-error/3042159#3042159 for a solution that works in VS 2010.

Ben Robbins