为什么 makensis.exe 尽管有效但仍返回错误级别 1?
我有一个可以运行的 NSIS 脚本。它编译,生成的安装程序工作正常。然而,makensis.exe 返回 1 而不是 0。这真的很痛苦,因为我在持续集成设置中使用它,现在我的 CI 认为构建失败了。
当我将项目从 SVN 切换到 Git,并对 NSIS 脚本做了一个微小的更改(我在两个地方更改了路径)时,这才开始。
- 我发现没有打印任何编译错误(即使使用 /V4)。
- 有 6 个警告,但它们与旧存储库中的 6 个警告相同,其中 makensis 返回 0。
- 我将之前的“errorlevel=0”输出与新的“errorlevel=1”输出进行了比较,发现没有显着差异。
- 它生成一个运行良好的安装程序。
- 我仍在使用 makensis.exe 的相同副本。
然而,它返回错误级别 1。
我确信几年前我遇到过这个问题,但我不记得我是如何解决它的。我想我刚刚升级到了 NSIS 的最新版本,但这次我不能这样做(我已经在使用最新版本了)。
I have a NSIS script that works. It compiles, the produced installer works fine. And yet, makensis.exe returns 1 instead of 0. This is a real pain because I use it in a continuous integration setup and now my CI thinks the build failed.
This just started when I switched my project from SVN to Git, and made one tiny change in the NSIS script (I changed a path in two places).
- There are NO compile errors printed (even with /V4) that I can find.
- There are 6 warnings but they are the same 6 it had in the old repo where makensis returned 0.
- I diffed the previous, "errorlevel=0" output with the new "errorlevel=1" output and found no significant differences.
- It produces an installer that works fine.
- I'm still using the same exact copy of makensis.exe.
And yet, it returns errorlevel 1.
I am certain that I had this problem a couple years ago, but I can't remember how I solved it. I think I just upgraded to the latest version of NSIS, but I can't do that this time (I'm already using the latest).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系。
问题出在执行 makensis.exe 的批处理文件中。它有这样的内容:
问题是 %errorlevel% 在循环开始时被评估为常量值。为了实际检查循环内的错误级别,您必须使用
!errorlevel!
而不是%errorlevel%
。另外,您还必须在批处理文件的顶部有SETLOCAL ENABLEDELAYEDEXPANSION
(我已经有了)。因此,显然之前的一些不重要的步骤(可能是 mkdiring 已经存在的目录)返回错误级别 1,然后我的检查认为它来自 makensis 调用。当然,这引出了一个永恒的问题:“这是如何运作的?”
Nevermind.
The problem was in my batch file that executed makensis.exe. It had something like this:
The problem is that %errorlevel% was being evaluated to a constant value at the beginning of the loop. In order to actually check the errorlevel within the loop, you have to use
!errorlevel!
not%errorlevel%
. Also you have to haveSETLOCAL ENABLEDELAYEDEXPANSION
at the top of your batch file (I had that already).So evidently some prior unimportant step (possibly mkdiring a dir that already existed) was returning errorlevel 1 and then my check was thinking it was from the makensis call. Of course this begs the eternal question: "how did this ever work?"