处理 nmake 错误级别/返回代码
我有一个基于 nmake 的项目,它依次调用 asp 编译器,这可能会引发错误,nmake 似乎可以识别该错误:
NMAKE : fatal error U1077: 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe' : return code '0x1'
但是,当我从批处理文件中调用 nmake 时,环境变量 %ERRORLEVEL% 保持设置为零:
nmake /NOLOGO
echo BUILD RETURNING: %ERRORLEVEL%
如果我 control-c nmake 任务,我最终会得到一个非零错误级别(它设置为 2),所以我的假设是我能够捕获错误,但是 nmake 不会冒泡非零错误从它的任务中退出代码。 或者,至少,我误入了陷阱。 任何帮助,将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,请发布您的批处理文件,以便我们了解您如何捕获错误。
也评论这篇文章,以便我可以再次阅读它。
作为第一个 git,我猜想是这样的:
nmakebatch.cmd usual nmake argument, without /NOLOGO
是一个将所有情况捕获到递增日志中的开始,而建筑。
First thing, please post your batch file so we can see how you trap the error.
Also comment this post so I can read it again.
As a first git, i'd guess something like:
nmakebatch.cmd usual nmake arguments, without /NOLOGO
Is a start for trapping all situations, into a incrementing log, while building.
您应该在批处理脚本中使用
exit /b %errorlevel%
这会将返回代码传递回 nmakeyou should use
exit /b %errorlevel%
in your batch script this will pass the return code back to nmake