tags:

views:

28

answers:

1

I have 2 versions of the same exe file for my project. The installer is supposed to pick one of the 2 versions depending on some conditions. In a normal case i would do File executable\myExe.exe. Because i now have 2 versions of the file, i would have to do something like File "${ExeSourcePath}\myExe.exe", and $ExeSourcePath is determined by checking various conditions. When compiling this code i get

File: "${ExeSourcePath}\myExe.exe" -> no files found.

Anyone knows why? I'm only allowed to use fixed paths with the File command or am i doing something wrong?

+1  A: 

${ExeSourcePath} is a precompiler define and $ExeSourcePath is a variable used at runtime, the File command can only use precompiler defines.

There are two ways you can handle this:

A) Include both files and decide at runtime based on the users system or choices made during install:

!include LogicLib.nsh
Section
ReadRegStr $0 HKLM "Software\foo\bar" baz
${If} $0 > 5
  File "c:\myproject\version2\app.exe"
${Else}
  File "c:\myproject\version1\app.exe"
${EndIf}
SectionEnd

B) Only include one file based on command line passed to makensis (/Dusev2 app.nsi) or something on your system:

Section
!define projectroot "c:\myproject"
!searchparse /noerrors /file ....... usev2 ;Or you can use !system etc
!ifdef usev2
  File "${projectroot}\version2\app.exe"
!else
  File "${projectroot}\version1\app.exe"
!endif
SectionEnd
Anders