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.
Go to Menu, Project, then Compile to compile and create the setup file. This will create a complete installer. Run the Setup and your application will be installed correctly. Innosetup offers an awesome alternative to create great looking Installers for free.
Inno Setup is a free installer for Windows programs by Jordan Russell and Martijn Laan.
/SUPPRESSMSGBOXESInstructs Setup to suppress message boxes. Only has an effect when combined with '/SILENT' or '/VERYSILENT'. The default response in situations where there's a choice is: Yes in a 'Keep newer file? ' situation.
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')
See Inno Setup Preprocessor: Expression Syntax.
After looking at many different options I found that this worked for me.
This is the command line to compile the setup file
"C:\Program Files (x86)\Inno Setup 5\iscc.exe" "MySetup.iss" /DVersion=1.2.3.4
In the setup file I added these lines, the first lines are to enable you to still run the script in the editor and ensure you would not get the error: Undeclared identifier: "Version"
#ifndef Version
#define Version = '0.0.0.0';
#endif
[Setup]
VersionInfoVersion={#Version}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With