Automatic app version increment

64 views
Skip to first unread message

Tom Buck

unread,
Aug 19, 2025, 10:58:05 AMAug 19
to innosetup
Hi,

Is it possible to automatically increment the app version number?

Currently have: #define MyAppVersion "1.1.0.2"

Would be good if the compiler could increase the number every time it ran?

Tom.

m. e.l.

unread,
Aug 19, 2025, 1:18:44 PMAug 19
to innosetup
At best, read the version string at preprocessing time from your app:
#define MyAppVersionString GetFileVersion('MyApp.exe')
#define MyAppProductVersionString GetFileProductVersion( 'MyApp.exe' )

then uses it:
[Setup]
VersionInfoVersion={#MyAppVersionString}
VersionInfoProductTextVersion={#MyAppProductVersionString}

Then you won't need to update it again in your script

David Powell

unread,
Aug 20, 2025, 7:46:40 AMAug 20
to innosetup
Hi Tom,

You could have the version number string stored in an INI file, then use the use the Inno Setup Preprocessor to read that, using the support functions ReadIni, StrToVersion and UnpackVersionComponents, then increment the build number, then do the opposite to PackVersionComponents, VersionToStr and WriteIni so that it is stored for the next compile.

You could even combine that with m. e.l.'s approach to take the highest version number, i.e. either that of the EXE or the incremented version number, before writing it back to the INI.

David

Tom Buck

unread,
Aug 21, 2025, 9:40:24 AMAug 21
to inno...@googlegroups.com
Hi guys,

This is what I came up with and it works perfectly.

Inno Script:
#define IniFile AddBackslash(SourcePath) + "Version.ini"
#define VersionStr ReadIni(IniFile, "Version", "Number", "1.0.0.0")
#define PackedVersion StrToVersion(VersionStr)
#define Major 0
#define Minor 0
#define Rev   0
#define Build 0
#expr UnpackVersionComponents(PackedVersion, Major, Minor, Rev, Build)
#define NewBuild (Build + 1)
#define NewPackedVersion PackVersionComponents(Major, Minor, Rev, NewBuild)
#define NewVersionStr VersionToStr(NewPackedVersion)
#expr WriteIni(IniFile, "Version", "Number", NewVersionStr)

[Setup]
AppVersion={#NewVersionStr}

Version.ini
[Version]
Number=1.7.0.4

Tom

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/0891f062-0d06-4d60-9eb2-8021c1ce072fn%40googlegroups.com.

Martijn Laan

unread,
Aug 21, 2025, 10:25:12 AMAug 21
to inno...@googlegroups.com
Hi,

Op 21-8-2025 om 15:40 schreef 'Tom Buck' via innosetup:
#define IniFile AddBackslash(SourcePath) + "Version.ini"
...

Nice work. Here's another way to write it:

#define GetVer(IniFile) \
  Local[0] = StrToVersion(ReadIni(IniFile, "Version", "Number", "1.0.0.0")), \
  UnpackVersionComponents(Local[0], Local[1], Local[2], Local[3], Local[4]), \
  Local[0] = VersionToStr(PackVersionComponents(Local[1], Local[2], Local[3], Local[4] + 1)), \
  WriteIni(IniFile, "Version", "Number", Local[0]), \
  Local[0]
[Setup]
AppVersion={#GetVer(AddBackslash(SourcePath) + "Version.ini")}

Greetings,
Martijn

Reply all
Reply to author
Forward
0 new messages