The exec resultproperty will capture the cmd interpreter exit code. The way you call exit in a batch file, although it does not end with cmd, only exits the script. The exit code from cmd will not be changed and will remain equal to zero. If you simply remove the \b option of the exit command, you will also terminate the interpreter and see that the exit code that you supply is being distributed.
if %errorlevel% neq 0 exit %errorlevel%
To crash, you can use the fail task, perhaps something like this:
<fail message="cmake_cross_compile.bat exited non-zero"> <condition> <not> <equals arg1="${BuildErrorCode}" arg2="0"/> </not> </condition> </fail>
Or you can set failonerror="true" to the exec task to crash immediately.
source share