views:

738

answers:

2

Hi all,

I have an nmake-based project which in turn calls the asp compiler, which can throw an error, which nmake seems to recognize:

NMAKE : fatal error U1077: 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe' : return code '0x1'

However, when I call nmake from within a batch file, the environment variable %ERRORLEVEL% remains set at zero:

nmake /NOLOGO echo BUILD RETURNING: %ERRORLEVEL%

If I control-c the nmake task, I do end up getting a non-zero ERRORLEVEL (it's set to 2) so my assumption is that I'm able to catch errors okay, but nmake isn't bubbling up the non-zero exit code from it's task. Or, at least, I'm mis-trapping it. Any help would be appreciated.

A: 

First thig, please post your batch file so we see how you trap the error.
Also comment this post so I read again.
As a first git, i'd guess something like:

nmakebatch.cmd usual nmake arguments, without /NOLOGO

@echo off
rem Args[x]: nmake arguments
echo.>> %~n0.log
echo %date% %time%>> %~n0.log
echo nmake /NOLOGO %*>> %~n0.log
nmake /NOLOGO %*
echo %errorlevel%>> %~n0.log

Is a start for trapping all situations, into a incrementing log, while building.

Jay
A: 

you should use exit /b %errorlevel% in your batch script this will pass the return code back to nmake

Jeremy E