The default Title of a Inno Setup Form is
Setup - %1
where %1 will be replaced by AppName from [Setup]-Section. I want to add the Version like this
Setup - MyProgramm 2.07.5
I've already managed to change the title by adding the [Messages]-Section and define the SetupWindowTitle. But this is fixed and i can't add the version string.
[Messages]
SetupWindowTitle=Setup - {AppName} {AppVersion}
This will result in
OK, I've found my mistake. The right syntax is
[Messages]
SetupWindowTitle=Setup - {#MyAppName} {#MyAppVersion}
And define some parameters at the beginning
#define MyAppName "MyProgram"
#define MyAppVersion GetStringFileInfo("package\MyProgram.exe", "FILEVERSION")
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
Set the AppVersion directive:
[Setup]
AppVersion=2.07.5
The value gets automatically into the SetupWindowTitle (indirectly via the default value of AppVerName directive).
You need Inno Setup 5.6 or newer.
You can also read the version from the executable:
[Setup]
AppVersion={#GetFileVersion(AddBackslash(SourcePath) + "MyProg.exe")}
See:
Using GetStringFileInfo in Setup section of Inno Setup
How do I automatically set the version of my Inno Setup installer according to my application version?
Related
My config screen:
Why is it that I can't select x64 in the list? In the Alarm Clock row there is Add / Edit in the drop-down list. But not for AlarmClockSetup.
I am posting step by step tutorial because Configuration in Visual Studio works differently than in Inno Setup:
Lets assume user wants to build 2 installers: for 32 and 64 bit OS (two separate setup.exe-s).
Define 2 Visual Studio Configuration(s) for this using standard Visual Studio Configuration manager dialog, choose any names for them you wish, I chose: "setup32" and "setup64", the result will look like this:
For EACH configuration define some symbol (called conf in this example) in Project Properties like this: conf=$(Configuration)
It is important to have this symbol set for EACH configuration
And now double check whether you have defined this symbol for EACH configuration
If symbol is not defined for some Configuration you receive "Error on line XXX: Undeclared identifier: conf."
Inno script to test the configuration:
[Setup]
AppName=InnoSetupProject1
AppVersion=1.0
DefaultDirName={pf}\InnoSetupProject1
DefaultGroupName=InnoSetupProject1
UninstallDisplayIcon={app}\InnoSetupProject1.exe
Compression=lzma2
SolidCompression=yes
OutputDir=userdocs:Output
OutputBaseFilename=InnoSetupProject1
PrivilegesRequired=lowest
[Files]
Source: "Script.iss"; DestDir: "{app}"
[Icons]
Name: "{group}\InnoSetupProject1"; Filename: "{app}\InnoSetupProject1.exe"
[Code]
// Place your code here...
procedure InitializeWIzard();
begin
MsgBox(ExpandConstant('Configuration: {#conf}'), mbinformation,mb_ok);
#if conf == "setup32"
MsgBox('This is setup32', mbinformation,mb_ok);
#endif
#if conf == "setup64"
MsgBox('This is setup64', mbinformation,mb_ok);
#endif
end;
How it works:
When you choose "setup32" in Configuration dropdown, the $(Configuration) MSBuild variable is initialized and set to "setup32".
This $(Configuration) is mapped to Symbol conf (defined in Project Properties) that can be used anywhere in the script.
Use it for conditioning the setup behaviour using pre-processor #if, for Pascal code or anywhere as {#conf}.
So when the configuration is set to setup32 and you build the script, the Inno pre-processor excludes the inappropriate parts from the script and only the correct message box is shown.
Use the #if for include/exclude files in your script, for [Setup] section directives, for defining the Output directory or anything, choose the Configuration and rebuild the setup.
I have created setup for Windows desktop WPF/C# application using Inno Setup 6.0 and it works fine. Just a small cosmetic issue - I would like to use a "semantic version". The version number in Windows has four components, major.minor.build.revision but I want to present major.minor.patch. The fourth component will be used by CI and has no relevance for user. In the current script, I have this:
#define AppVersion GetFileVersion("..\app\bin\Release\app.exe")
... which later gets used as:
[Setup]
AppVersion=AppVersion
OutputBaseFilename=app.{#AppVersion}.x64
The result is app.1.0.1.781.x64.exe created by Inno Setup, so I'm looking for a way to cut off the last version component - .781. So far I haven't figured out how to invoke a script function for that purpose. I could add function in [Code] section but it will be defined after [Setup] section and apparently cannot be called in [Setup] section?
Is it possible to modify the values of AppVersion and OutputBaseFilename in Pascal script, for instance in InitializeSetup()?
You can use GetVersionComponents preprocessor function (ParseVersion before Inno Setup 6.1):
#define AppVerText() \
GetVersionComponents('..\app\bin\Release\app.exe', \
Local[0], Local[1], Local[2], Local[3]), \
Str(Local[0]) + "." + Str(Local[1]) + "." + Str(Local[2])
Then you can use this in your [Setup] section:
AppVersion={#AppVerText}
You can use this for OutputBaseFilename too:
OutputBaseFilename=app.{#AppVerText}.x64
In my *.iss installer script I'm passing application version to the VersionInfoVersion param
VersionInfoVersion = {#ver}
where {#ver} is 0.4.0.201801182
According to Inno Setup documentation format is correct. However, I'm getting the following error:
Value of [Setup] section directive "VersionInfoVersion" is invalid.
Compile aborted.
The problem is the last section of your version. It appears that each section only supports up to 65,535. For example:
#define ver "0.4.0.65535" ;this works
#define ver "0.4.0.65536" ;this fails
I want to add a shortcut to my program in the start menu as follows:
MyAppPublisher\MyAppName\MyAppName
I have this in my script:
DefaultGroupName={#MyAppPublisher}
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
But the start menu folder is always:
MyAppName\MyAppName
Any ideas?
It's as easy as specifying this path in the Name parameter of the entry in the [Icons] section. Your current script creates a shortcut like MyAppPublisher\MyAppName, this one will do what you need:
#define MyAppName "MyAppName"
#define MyAppExeName "MyProg.exe"
#define MyAppPublisher "MyAppPublisher"
[Setup]
AppName={#MyAppName}
AppVersion=1.5
DefaultDirName={pf}\My Program
DefaultGroupName={#MyAppPublisher}
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "{#MyAppExeName}"; DestDir: "{app}"
[Icons]
; notice the full path to the created shortcut, {group} is taken from the Select
; Start Menu Folder page edit box (if shown), which is by default taken from the
; DefaultGroupName directive value; this start menu folder path is then followed
; by the tail of the shortcut path
Name: "{group}\{#MyAppName}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
If you want the group to be in a subfolder, you need to specify the sub folder.
The best way to do this is to append it to the end of the DefaultGroupName directive which will show the correct info in the setup wizard and allow the user to change it to as single folder or another location entirely if they wish.
DefaultGroupName={#MyAppPublisher}\{#MyAppName}
Note that the Start Menu in Windows 8 is not heirachical so any nesting won't be seen anyway.
Found it, my script suggested in the question was correct, for some reason I needed to generate a new GUID for the script for the changes to take effect
I am using Inno Setup to generate the installer of my application. How can set the version number of the setup.exe (VersionInfoVersion) generated by Inno to match with the version number of my application automatically? Now every time I deploy a new version of my application I need to update the version number manually.
Now I'm doing this:
[Setup]
VersionInfoVersion=1.2.2.0 //writing the value manually
I want something like this:
[Setup]
VersionInfoVersion={Get the version of my app}
You can use the Inno Setup Preprocessor GetVersionNumbersString function like this
#define ApplicationName 'Application Name'
#define ApplicationVersion GetVersionNumbersString('Application.exe')
[Setup]
AppName={#ApplicationName}
AppVerName={#ApplicationName} {#ApplicationVersion}
VersionInfoVersion={#ApplicationVersion}
Another way to do it by using a command line argument :
[Setup]
AppVersion={#MyAppVersion}
and you just call your script as follow from a cmd :
cd C:\Program Files (x86)\Inno Setup 5
iscc /dMyAppVersion="10.0.0.1" "C:\MyPath\MyScript.iss"
It emulate #define MyAppVersion="10.0.0.1" in the iss script.
If you are using CakeBuild, you can pass this argument as
string CurrentVersion = "10.0.0.1";
InnoSetupSettings settings = new InnoSetupSettings();
settings.Defines= new Dictionary<string, string>
{
{ "MyAppVersion", CurrentVersion },
};
InnoSetup("C:\MyPath\MyScript.iss", settings);
In case you have a pure webinstaller, the accepted solution won't work,
because you simply won't have an application.exe to get the version number from.
I'm using Nant and a build.xml file with version number properties, which i manually bump, before i'm rebuilding the innosetup installers.
My *.iss files contain a special token #APPVERSION#, which is replaced
with the version number during the build process. This is done via a copy operation with an applied filterchain, see below.
InnoSetup Script (*.iss)
// the -APPVERSION- token is replaced during the nant build process
#define AppVersion "#APPVERSION#"
nant build.xml:
<!-- Version -->
<property name="product.Name" value="My Software"/>
<property name="version.Major" value="1"/>
<property name="version.Minor" value="2"/>
<property name="version.BuildNumber" value="3"/>
<property name="product.Version"
value="${version.Major}.${version.Minor}.${version.BuildNumber}"/>
<!-- build task -->
<target name="bump-version"
description="Inserts the current version number into the InnoScript.">
<copy todir="${dir.Build}" overwrite="true">
<fileset basedir="${dir.Base}/innosetup/">
<include name="product-webinstaller-w32.iss"/>
<include name="product-webinstaller-w64.iss"/>
</fileset>
<filterchain>
<replacetokens>
<token key="APPVERSION" value="${product.Version}"/>
</replacetokens>
</filterchain>
</copy>
</target>
I had some problems with getting this to work, so just contributing my solution.
app.iss:
[Setup]
#include "Config.txt"
#define AppVersion GetFileVersion("Input\" + AppExec)
AppName={#AppName}
AppVersion={#AppVersion}
Config.txt:
#define AppName "App"
#define AppExec "App.exe"
As others have mentioned, the GetFileVersion or GetStringFileInfo preprocessor functions can be used for that.
Some important info, improvements and helpful additions:
You can either use an absolute path to the exe, or a path relative to the .iss file
You can include existing defines in your statement by just writing their name, and concatenate defines with the + operator:
#define MyAppPath "..\Win32\Release\" + MyAppExeName
If you want you can easily remove parts of the version number from the right by using the function RemoveFileExt, e. g. convert 3.1.2.0 to 3.1.2:
#define MyAppVersion RemoveFileExt(GetFileVersion(MyAppPath))
You can use the defines MyAppExeName and MyAppPath in the subsequent options like Messages, Files or Icons
Working example:
#define MyAppName "Application Name"
#define MyAppExeName "Application.exe"
#define MyAppPath "..\Win32\Release\" + MyAppExeName
#define MyAppVersion RemoveFileExt(GetFileVersion(MyAppPath))
[Setup]
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
VersionInfoVersion={#MyAppVersion}
OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows
...
[Messages]
SetupWindowTitle=Setup - {#MyAppName} {#MyAppVersion}
...
[Files]
Source: {#MyAppPath}; DestDir: "{app}"; Flags: ignoreversion; Tasks: desktopicon
...
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
In my case, I would like to define the version string from a file. I don't have an EXE, since my installer is packing an embedded Python program. So I define the version number in a one-line text file like such (this is created from a git tag statement beforehand):
..\Build\app_version.txt:
v1.2.1
In the Inno Setup, I used a pre-processor define statement to set the version throughout the text.
#define VerFileNum FileOpen("..\Build\app_version.txt")
#define MyAppVersion Trim(StringChange(FileRead(VerFileNum),"v",""))
Here, I used Trim() and StringChange() to remove the leading "v" and trailing spaces from the string. Later in the setup section, the AppVersion value can be set using the pre-processor definition:
[Setup]
AppVersion={#MyAppVersion}
The Inno Setup pre-processor has quite an extensive set of functions already defined: Inno setup pre-processor functions
After quite some time trying other methods, the way it worked for me was to use a relative path (I have the .iss file in a folder and the EXE file two levels above).
; Extract File Version from EXE
#define MyAppVersion GetFileVersion("..\..\Release\CSClave.exe")