I want my Inno Setup script to be build using the command line, and I want to pass in the product version number as a parameter. I am trying to implement it like so:
[setup]
VersionInfoVersion={param:version|0.0.0.0}
However the compiler informs me this is invalid for that directive. I have read this post on how to pass in custom parameters from the command line and assume I should just be able to pass in something like:
compil32 /cc "c:\isetup\samples\my script.iss" /version=1.0.0.0
I have also tried the suggestion from this post and tried doing the following:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion('#PathToMyBinary\MyBinary.dll')
VersionInfoVersion={#ApplicationVersion}
But it doesn't seem to return anything. Both approaches seem valid to me so I'm hoping someone can explain where I am going wrong.
Assuming you define the version via a pre-processor variable like:
[Setup]
VersionInfoVersion={#ApplicationVersion}
To set the version on a command-line, you have to use the ISCC.exe
command-line compiler and its /D
switch:
ISCC.exe Example1.iss /DApplicationVersion=1.2.3.4
If you want to provide a default value for the version, so the script can compile even without defining the variable on the command line, use #ifndef
at the top of the script:
#ifndef ApplicationVersion
#define ApplicationVersion "1.2.3.4"
#endif
To read the version from a binary, you are correctly using the GetFileVersion
pre-processor function.
But your syntax to make up the path is wrong.
A correct syntax is PathToMyBinary + '\MyBinary.dll'
, like:
#define PathToMyBinary "C:\bin\x64\Release"
#define ApplicationVersion GetFileVersion(PathToMyBinary + '\MyBinary.dll')