I made the following test installation script:
I'm calling makensis.exe like this:!include "MUI.nsh"
!define TESTDEFINE "in script"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Name "TestSetup"
OutFile "c:\temp\TestSetup.exe"
InstallDir "c:\temp\My application"
ShowInstDetails show
Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "c:\temp\files\*.*"
MessageBox MB_OK "Def is ${TESTDEFINE}"
SectionEnd
"C:\Program Files (x86)\NSIS\makensis.exe" "testscript.nsi" /DTESTDEFINE="from command line"
If working correctly, then the pop-up message window when the script creates the setup EXE should read "Def is from command line".
But it instead reads "Def is in script"
If I remove TESTDEFINE from the script, I get this compilation error:
If I have it defined in the script, the compilation completes with no errors and makensis says:C:\temp>"C:\Program Files (x86)\NSIS\makensis.exe" "testscript.nsi" /DTESTDEFINE="from command line"
Processing config: C:\Program Files (x86)\NSIS\nsisconf.nsh
Processing script file: "testscript.nsi" (ACP)
warning 6000: unknown variable/constant "{TESTDEFINE}" detected, ignoring (testscript.nsi:21)
Command line defined: "TESTDEFINE=from command line"
Processed 1 file, writing output (x86-ansi):
warning 7998: ANSI targets are deprecated
Output: "c:\temp\TestSetup.exe"
Install: 2 pages (128 bytes), 1 section (2072 bytes), 47 instructions (1316 bytes), 68 strings (1211 bytes), 1 language table (262 bytes).
Using zlib compression.
EXE header size: 51200 / 38400 bytes
Install code: 1248 / 4429 bytes
Install data: 852 / 2107 bytes
CRC (0xFC6E3AA7): 4 / 4 bytes
Total size: 53304 / 44940 bytes (118.6%)
2 warnings:
6000: unknown variable/constant "{TESTDEFINE}" detected, ignoring (testscript.nsi:21)
Command line defined: "TESTDEFINE=from command line"
But it does not change TESTDEFINE in the script.
What am I doing wrong?
Dave