处理 nmake 错误级别/返回代码

发布于 2024-07-09 12:48:42 字数 466 浏览 8 评论 0原文

我有一个基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鸠魁 2024-07-16 12:48:42

首先,请发布您的批处理文件,以便我们了解您如何捕获错误。
也评论这篇文章,以便我可以再次阅读它。
作为第一个 git,我猜想是这样的:

nmakebatch.cmd usual nmake argument, 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

是一个将所有情况捕获到递增日志中的开始,而建筑。

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

@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.

溺深海 2024-07-16 12:48:42

您应该在批处理脚本中使用 exit /b %errorlevel% 这会将返回代码传递回 nmake

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文