Incrementing build number every time the script is compiled

From ISXKB

(Difference between revisions)
Jump to: navigation, search
(See also)
m (Implementation)
Line 5: Line 5:
== Implementation ==
== Implementation ==
-
Add the following few lines to the top of your script. When beeing called will create a file BuildInfo.ini to the script's directory.
+
Add the following preprocessor lines to the top of your script. When processed they create a file BuildInfo.ini in the script's directory.
<pre>
<pre>
; Read the previuos build number. If there is none take 0 instead.
; Read the previuos build number. If there is none take 0 instead.
Line 13: Line 13:
#expr BuildNum = BuildNum + 1
#expr BuildNum = BuildNum + 1
-
; Store the number in the ini file for the next build
+
; Store the number in the ini file for the next build.
#expr WriteIni(SourcePath + "\\BuildInfo.ini","Info","Build", BuildNum)
#expr WriteIni(SourcePath + "\\BuildInfo.ini","Info","Build", BuildNum)
</pre>
</pre>

Revision as of 09:54, 20 January 2010

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 shows how the obtained build number is used to create a new output file containing the number every time the script is beeing compiled.

[Setup]
OutputBaseFilename=Setup_{#BuildNum}

It creates files called 'Setup_1.exe', 'Setup_2.exe', 'Setup_3.exe', etc.

See also

Personal tools
Ads: