1

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.

anjunatl
  • 1,027
  • 2
  • 11
  • 24
  • It already fails the build when a post build command returns an error exit code. What's wrong with your version of jslint? – Hans Passant Aug 22 '11 at 18:37
  • It appears to be wrapped in jslint4java and packaged with several other bug-checking solutions in a jar, and that jar is run. Output from jslint is going to a text file and not being raised up, I suppose. – anjunatl Aug 22 '11 at 18:40
  • 1
    Well, write a little C# program that parses that file. Assign Environment.ExitCode – Hans Passant Aug 22 '11 at 18:42
  • @Hans Write that as an official answer and I'll mark it. It worked. =) – anjunatl Aug 24 '11 at 19:23

2 Answers2

3

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
Rob Hunter
  • 2,787
  • 4
  • 35
  • 52
0

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..

Baz1nga
  • 15,485
  • 3
  • 35
  • 61