Monday, October 15, 2007

REMs don't sleep

Let's say you have a .BAT file with a command like

c:\bin\dcc32.exe   [parms to compile a Delphi program]

It will return an %errorlevel% of greater than zero if the program does not compile, zero if it does.

Since I was testing this by double-clicking, I put a PAUSE statement right after it to see the output of the compile step. 

c:\bin\dcc32.exe   [parms to compile a Delphi program]
pause

Once the whole build project started working, I left the PAUSE in but REM'ed it out so I could remember what I had done in case I needed to go back and debug later.

c:\bin\dcc32.exe   [parms to compile a Delphi program]
rem pause

It turns out that REM is an "active" statement in a .BAT file and sets %errorlevel% to zero!  When the compile line really did fail, the error was being masked by the REM right after it, so the MSBuild project kept going as if nothing was wrong.  Once the REM line was removed, the MSBuild project failed as it should.

No comments: