我想通过/D
我的可执行文件传递路径(通过命令行arg到脚本编译器),以使我的脚本使用来确定应用程序的版本号GetFileVersion
,但是我的语法不正确。我该如何传递论点GetFileVersion
?错误是:输入文件中的非法字符:'#'(0x23)
#define srcpath SOURCEPATH
#define ApplicationVersion GetFileVersion(#srcpath)//error here!!!!!!
[Setup]
AppVersion={#ApplicationVersion}
[Files]
Source: "MyDllTesting.dll"; Flags: dontcopy
Source: "{srcpath}MyApplication1.exe"; DestDir: "{app}\MyApplication1"
首先,SOURCEPATH
是Inno Setup预处理器的预定义变量,因此您需要在命令行“变量”中使用另一个名称。我将使用SOURCE_PATH
。
其次,正确的语法是:
#define ApplicationVersion GetFileVersion(SOURCE_PATH)
(即没有哈希)
为什么在我的答案中没有哈希,
为什么预处理器在#include指令中的行为与在[Files]节中的Inno Setup脚本不同
尽管原因基本相同,但为什么在SOURCEPATH
此之前不使用哈希:
#define srcpath SOURCEPATH
相反,您在[Files]
节条目中缺少哈希。正确的语法是:
[Files]
Source: "{#srcpath}MyApplication1.exe"; DestDir: "{app}\MyApplication1"
无需定义srcpath
变量。SOURCE_PATH
也是可变的 因此,您可以在任何表达式中直接使用它:
#define ApplicationVersion GetFileVersion(SOURCE_PATH)
[Files]
Source: "{#SOURCE_PATH}MyApplication1.exe"; DestDir: "{app}\MyApplication1"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句