Incrementing build number every time the script is compiled
From ISXKB
This article is more or less a takeover from the old ISXKB 339KB.
Contents |
Introduction
Inno Setup's preprocessor (ISPP) can store a new build number in an ini file every time the script is compiled. This build number can then be used for certain tasks, for instance to change the output file name.
Implementation
Add the following preprocessor lines to the top of your script. When processed they create a file BuildInfo.ini in the script's directory.
; Read the previuos build number. If there is none take 0 instead. #define BuildNum Int(ReadIni(SourcePath + "\\BuildInfo.ini","Info","Build","0")) ; Increment the build number by one. #expr BuildNum = BuildNum + 1 ; Store the number in the ini file for the next build. #expr WriteIni(SourcePath + "\\BuildInfo.ini","Info","Build", BuildNum)
Example
This example shows how the retrieved build number is used to create a new output file containing the number every time the script is compiled.
[Setup]
OutputBaseFilename=Setup_{#BuildNum}
It creates files called 'Setup_1.exe', 'Setup_2.exe', 'Setup_3.exe', etc.
