将版本号传递给 Inno Setup 编译器
Passing in version number to Inno Setup compiler
我希望使用命令行构建我的 Inno Setup 脚本,并且我希望将产品版本号作为参数传递。我正在尝试像这样实现它:
[setup]
VersionInfoVersion={param:version|0.0.0.0}
但是编译器告诉我这对于那个指令是无效的。我已经阅读了 this post 关于如何从命令行传递自定义参数并假设我应该能够传递类似的东西:
compil32 /cc "c:\isetup\samples\my script.iss" /version=1.0.0.0
我也尝试了 this post 的建议并尝试执行以下操作:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion('#PathToMyBinary\MyBinary.dll')
VersionInfoVersion={#ApplicationVersion}
但它似乎 return 什么都没有。这两种方法对我来说似乎都有效,所以我希望有人能解释我哪里出错了。
假设您通过预处理器变量定义版本,例如:
[Setup]
VersionInfoVersion={#ApplicationVersion}
要在命令行上设置版本,您必须使用 ISCC.exe
command-line compiler and its /D
switch:
ISCC.exe Example1.iss /DApplicationVersion=1.2.3.4
如果你想为版本提供一个默认值,这样即使不在命令行上定义变量脚本也可以编译,在顶部使用#ifndef
的脚本:
#ifndef ApplicationVersion
#define ApplicationVersion "1.2.3.4"
#endif
要从二进制文件中读取版本,您正确使用了 GetFileVersion
pre-processor function。
但是你组成路径的语法是错误的。
正确的语法是 PathToMyBinary + '\MyBinary.dll'
,例如:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion(PathToMyBinary + '\MyBinary.dll')
在查看了许多不同的选项后,我发现这对我有用。
这是编译安装文件的命令行
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "MySetup.iss" /DVersion=1.2.3.4
在安装文件中我添加了这些行,第一行是为了让您仍然可以在编辑器中 运行 脚本并确保您不会收到错误:Undeclared identifier: "Version"
#ifndef Version
#define Version = '0.0.0.0';
#endif
[Setup]
VersionInfoVersion={#Version}
为了让我的安装脚本(iss 文件)工作,我必须从我的脚本中删除#define ApplicationVersion 行。一旦我这样做了,它就识别出了我的 /DApplicationVersion=8 输入参数。
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "install.iss" /DApplicationVersion=8
我希望使用命令行构建我的 Inno Setup 脚本,并且我希望将产品版本号作为参数传递。我正在尝试像这样实现它:
[setup]
VersionInfoVersion={param:version|0.0.0.0}
但是编译器告诉我这对于那个指令是无效的。我已经阅读了 this post 关于如何从命令行传递自定义参数并假设我应该能够传递类似的东西:
compil32 /cc "c:\isetup\samples\my script.iss" /version=1.0.0.0
我也尝试了 this post 的建议并尝试执行以下操作:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion('#PathToMyBinary\MyBinary.dll')
VersionInfoVersion={#ApplicationVersion}
但它似乎 return 什么都没有。这两种方法对我来说似乎都有效,所以我希望有人能解释我哪里出错了。
假设您通过预处理器变量定义版本,例如:
[Setup]
VersionInfoVersion={#ApplicationVersion}
要在命令行上设置版本,您必须使用 ISCC.exe
command-line compiler and its /D
switch:
ISCC.exe Example1.iss /DApplicationVersion=1.2.3.4
如果你想为版本提供一个默认值,这样即使不在命令行上定义变量脚本也可以编译,在顶部使用#ifndef
的脚本:
#ifndef ApplicationVersion
#define ApplicationVersion "1.2.3.4"
#endif
要从二进制文件中读取版本,您正确使用了 GetFileVersion
pre-processor function。
但是你组成路径的语法是错误的。
正确的语法是 PathToMyBinary + '\MyBinary.dll'
,例如:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion(PathToMyBinary + '\MyBinary.dll')
在查看了许多不同的选项后,我发现这对我有用。
这是编译安装文件的命令行
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "MySetup.iss" /DVersion=1.2.3.4
在安装文件中我添加了这些行,第一行是为了让您仍然可以在编辑器中 运行 脚本并确保您不会收到错误:Undeclared identifier: "Version"
#ifndef Version
#define Version = '0.0.0.0';
#endif
[Setup]
VersionInfoVersion={#Version}
为了让我的安装脚本(iss 文件)工作,我必须从我的脚本中删除#define ApplicationVersion 行。一旦我这样做了,它就识别出了我的 /DApplicationVersion=8 输入参数。
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "install.iss" /DApplicationVersion=8