问题
Is there a way to force the build to fail given certain conditions in the post-build event? The package I'm working with runs jslint and a few other solutions all together on post-build, I would like Visual Studio to fail if jslint produces an error.
I am aware of the jslint plugin for VS2010 that will fail the build on error, but my requirements are restricting me to using the packaged bugchecking solution in which jslint is contained.
回答1:
Post build events are basically batch scripts - you can check for error return values using "if ERRORLEVEL".
Example of a failing copy command:
copy "$(ProjectDir)myfile.ext" "$(TargetDir)"
if ERRORLEVEL 1 goto EXIT
:EXIT
回答2:
I believe there is an attribute called continueonerror and breakonerror etc that can be added to these post build events. Can you take a look at the same.. I hv this implemented but right nw no access to my machine will get back to you if this doesn't solve your problem or if smbody else can't..
来源:https://stackoverflow.com/questions/7151484/fail-on-post-build-event