Installing mutual exclusive Versions of Programs
From NSIS Wiki
Jump to navigationJump to search
An undocumented side effect of SetOutPath is that it also affects the directory where the files specified by File are located in the installer archive.
The order in the source file instead of the execution order during installation is relevant in this case. This difference could be used to place mutual exclusive versions of programs in separate archive directories.
This assumes that this undocumented feature will not be changed in future NSIS releases.
For a real world use case, please see the smartmontools installer.
Example
Name "Installer" OutFile "install.exe" RequestExecutionLevel user InstallDir "$DESKTOP\nsis-test" !include "LogicLib.nsh" Page components Page instfiles Section "64-bit version" X64 SectionEnd Section "Programs" !macro FileExe name ${IfNot} ${SectionIsSelected} ${X64} Goto +2 SetOutPath "$INSTDIR\bin32" ; never executed but sets archive dir to 'bin32' File 'build\x86\${name}' ${Else} Goto +2 SetOutPath "$INSTDIR\bin64" ; never executed but sets archive dir to 'bin64' File 'build\x86_64\${name}' ${EndIf} !macroend SetOutPath "$INSTDIR" ; sets install path !insertmacro FileExe "one.exe" !insertmacro FileExe "two.exe" SectionEnd
The installer will then contain the following directories and files:
bin32/one.exe bin64/one.exe bin32/two.exe bin64/two.exe
The following files will be installed from either bin32 or bin64 directory:
$INSTDIR/one.exe $INSTDIR/two.exe