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