Isaac Bolinger
Isaac Bolinger

Reputation: 7388

How can I have a pre-build event halt the build if something went wrong with it (VS 2010/C#)?

I'm executing a simple console exe program in a pre build event that consolidates a bunch of xml files into one big xml file. This will vastly cut down on spin-up time when the program is run.

Is there a special return code I can use that will inform VS-2010 that something went wrong with the pre-build event and will cause the build to halt?

Is there some other solution to this?

Thanks,

Isaac

Upvotes: 0

Views: 392

Answers (1)

Hans Passant
Hans Passant

Reputation: 942438

Build events normally abort when one of their commands fail. If you have to such condition then you can create one with the exit /b command. Like this:

if exist "foo.bar" goto good
exit /b 42
:good

The exit code is fairly arbitrary, anything other than 0 causes a build abort.

Upvotes: 2

Related Questions