0
我正在为我的同事安装的系统构建安装程序,但是有几件事情会因目标机器而异,包括编译机器上要安装的文件的位置。我想我可以在源文件中设置一个"gflag"(使用!define
),并在致电makensis.exe
(使用/D
)时覆盖它,但我甚至无法让我的安装程序识别出/D
标志已通过。!define和/ D的优先级 - 如何设置可覆盖的默认值?
更多相关文档是/h
标志背后:
PS C:\> &"C:\Program Files (x86)\NSIS\makensis.exe" /h
Usage:
makensis [ option | script.nsi | - ] [...]
Options:
#...
/Ddefine[=value] defines the symbol "define" for the script [to value]
#...
我使用这个NSIS代码:
!ifndef test
!define test Foo
!endif
Section
DetailPrint "${test}"
SectionEnd
我编译安装在PowerShell中:
&"C:\Program Files (x86)\NSIS\makensis.exe" "C:\path\to\test.nsi" /Dtest=Bar
其中输出,我看到这个:
Command line defined: "test=Bar"
安装程序成功创建,但它打印Foo
,而它应该打印Bar
。如果我评论!define test Foo
,我在编译时得到一个警告:
1 warning:
unknown variable/constant "{test}" detected, ignoring (C:\Mach4\Installer\test.nsi:6)
然后${test}
打印,表明gflag没有价值。为什么它没有值Bar
?