1

I'd like to control the branding for my NSIS installer by passing a parameter to makensis:

makensis.exe /DCOMPANY_X=1 installer.nsi  

The following are the first few lines listed in my NSI file:

!ifdef ${COMPANY_X}
  !define PRODUCT_NAME "Widget Pro"
  !define PRODUCT_VERSION "v2.0"
  !define PRODUCT_PUBLISHER "ACE Company"
  !define PRODUCT_WEB_SITE "www.ace.com"
  !define PRODUCT_COPYRIGHT "Copyright 2013 Ace"
!else
  !define PRODUCT_NAME "Widget Maker"
  !define PRODUCT_VERSION "v12.3"
  !define PRODUCT_PUBLISHER "ACME CO"
  !define PRODUCT_WEB_SITE "www.acme.com"
  !define PRODUCT_COPYRIGHT "Copyright 2013 ACME"
!endif

I use these defines throughout my script.

The problem I'm encountering is that even with COMPANY_X defined on the command line, execution is passing through to the second block of defines (ACME).

Being new to NSIS, I'm sure there's a better way to handle this. I'd also like to use a switch statement to define multiple companies. If I do this, the compiler warns me that I need to place this code in a section or function.

One thing that might complicate a solution for this is that I'm signing my uinstaller with a two pass process: http://nsis.sourceforge.net/Signing_an_Uninstaller

Kudos to the NSIS team and all the contributors. No way I'd ever go back to InstallShield.

Thanks in advance for any help.

4

1 回答 1

3

!ifdef ${COMPANY_X} is actually going to check if 1 is defined!

The syntax is !ifdef name_of_define: !ifdef COMPANY_X

...or if the content of the define matters: !if ${COMPANY_X} = 1

于 2013-03-30T04:59:05.190 回答