Help save net neutrality! Learn more.
Close

#751 <exec> Task Always Returns 0 for Batch Files on Windows XP

0.91-alpha2
open
nobody
Tasks (408)
5
2010-10-04
2010-10-04
No

I\\\'m encountering an issue with the <exec> task on batch files in my NAnt project files. When running on Windows XP SP 3 (but not Windows Vista or Windows Server 2008) and using NAnt 0.85 or 0.91alpha2, the <exec> task will always succeed (returning an error code of 0) regardless of what the executed batch file returned.

As an example, I wrote the following NAnt target:

<target name=\\\"build\\\">
<exec program=\\\"fail.bat\\\"
failonerror=\\\"false\\\" resultproperty=\\\"makeall.result\\\">
</exec>
<echo message=\\\"Makeall task returned result ${makeall.result}\\\"/>
<fail if=\\\"${int::parse(makeall.result) != 0}\\\">Encountered ${makeall.result} errors.</fail>
</target>

which calls the following batch file:

exit /b 1

Under normal operation (Windows Vista), the result of running NAnt is:

build:

[exec] C:\\\\Users\\\\Will\\\\Code>exit /b 1
[exec] C:\\\\Users\\\\Will\\\\Code\\\\fail.build(6,4):
[exec] External Program Failed: C:\\\\Users\\\\Will\\\\Code\\\\fail.bat (return code was 1)
[echo] Makeall task returned result 1

BUILD FAILED - 1 non-fatal error(s), 0 warning(s)

But on two different Windows XP SP3 machines, the result of running NAnt is:

build:

[exec] C:\\\\Documents and Settings\\\\Will\\\\My Documents\\\\My Code>exit /b 1
[echo] Makeall task returned result 0

BUILD SUCCEEDED

Discussion


Log in to post a comment.