Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I conditionally compile an NSIS script based on commandline parameters?

Tags:

nsis

I'm trying to generalize a setup file by externally passing the version number. I want to be able to do this:

makensis myscript.nsi parameter=value

and then read the parameter within the script, so that using the same script I can generate differently versioned executables. I found this & this, but they seem to be for passing commandline parameters to the generated setup.exe. Is this possible, and how?

like image 810
Rex Avatar asked Nov 30 '11 12:11

Rex


People also ask

How to compile NSIS script?

To compile you can right-click your . nsi file and select Compile NSIS Script. This will cause MakeNSISW, the NSIS Compiler Interface, to launch and call MakeNSIS to compile your script.

What is a NSIS script?

Nullsoft Scriptable Install System (NSIS) is a script-driven installer authoring tool for Microsoft Windows backed by Nullsoft, the creators of Winamp. NSIS is released under a combination of free software licenses, primarily the zlib license.

Does NSIS work on Linux?

The NSIS installer compiler will work under Linux and MacOSX but you will have to download the source and compile it yourself.


1 Answers

You can add symbols to the globally defined list from the command line using the /D switch:

makensis /DMyVersion="1.0.1" install.nsi

Then you can use them using the ${} syntax:

!ifdef MyVersion
    StrCpy $Version "${MyInstallerName}"
!else
    StrCpy $Version "1.0.0"
!endif

Also of possible interest is the GetVersion plugin discussed in this SO question: NSIS - put EXE version into name of installer

like image 192
David Hall Avatar answered Sep 28 '22 10:09

David Hall