Question

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

Was it helpful?

Solution

Nevermind.

The problem was in my batch file that executed makensis.exe. It had something like this:

for %%A in (*.nsi) do (
    makensis.exe "%%A"
    if %errorlevel% neq 0
        echo %%A Failed.
    )
)

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 have SETLOCAL 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?"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top