题
我有一个基于NSIS的安装程序,我需要能够在不同条件下生成略有不同的版本。
如果在磁盘上存在特定文件,则可以在编译时易于建立条件,则可以使用替代品牌。我知道我可以使用makensis.exe的命令行选项来提供此行为,但是如果编译器可以为我照顾这个行为,那就更好了。
有没有一种方法来制作编译时间“ Ifexist”类型逻辑?
解决方案
!macro CompileTimeIfFileExist path define
!tempfile tmpinc
!system 'IF EXIST "${path}" echo !define ${define} > "${tmpinc}"'
!include "${tmpinc}"
!delfile "${tmpinc}"
!undef tmpinc
!macroend
Section
!insertmacro CompileTimeIfFileExist "$%windir%\explorer.exe" itsThere
!ifdef itsThere
MessageBox mb_Topmost yes
!else
MessageBox mb_Topmost no
!endif
SectionEnd
注意:这里使用的!系统命令假设您正在Windows上编译
其他提示
我没有您对编译时文件检测的通用问题的答案,但是我确实可以解决您想完成的事情。
我的安装人员使用这样的东西:
在文件custombranding.nsh中:
!define CUSTOM_BRANDING
!define APPNAME "Brand X"
!define LOGO "C:\Brand_X_Logo.png"
在主安装程序脚本中:
!include /NONFATAL "CustomBranding.nsh"
!ifndef CUSTOM_BRANDING
!define APPNAME "Generic"
!define LOGO "C:\Generic_Logo.png"
!endif
这是您要问的那种“替代品牌”?
不隶属于 StackOverflow