03

Handling Version Numbering in FinalBuilder

A common question on our newsgroups is what the best way is to deal with incrementing version numbers in the compiler actions. This article is an attempt to explain some techniques for doing just that!

Using the built in AutoIncrement options

Most of the FinalBuilder Compiler Actions (Delphi, VB6, VS.NET, C++Builder) provide an option to AutoIncrement the build number every time the action is run. When this option is enabled, FinalBuilder saves that value in the data file (.fbd) associated with the FinalBuilder project file. The fbd file contains an entry for each action that has AutoIncrement Build Number enabled that looks something like this :

[{C4CDD351-B821-434E-ACF7-B98D59FEE8B4}]
Description=Build VS.NET Solution
AssemblyVersion=1|0|0|2

What normally happens with the properties of an action is that they are saved in the project file. This still happens when AutoIncrement is enabled, however the property is also written to the fbd file, and the next time the project is loaded the value is retrieved from the fbd file after the action has loaded. So basically the fbd file provides persistence for properties outside and independent of the project file (because the project file may be read only, in which case AutoIncrement wouldn't work!).

The down side to using this technique is that if you just want to test a build and not increment the build numbers you need to turn off AutoIncrement Before running the build and remember to turn it on again later.

Another common question is how to have all the dll's or assemblies or exe's use the same version numbers. I'll address that question later in this article.

Storing version numbers in Ini Files

This technique is popular with finalbuilder users because it offers more control over when the build numbers are incremented. In the above example the build number is incremented if the action succeeds, however a successfull build usually involves more than just one action. Using an Ini file to persist the build numbers allows you to delay writing the incremented value until you are sure the build succeeded.

To get started, create a blank Ini file and add some entries with your starting values :

[VersionInfo]
MajorVersion=1
MinorVersion=0
ReleaseVersion=1
BuildVersion=123

Save the inifile and then in FinalBuilder add an Action group and 4 Read Ini Actions to that group.

You will need some FinalBuilder variables to hold your version numbers, so go and declare 4 variables MAJORVERSION,MINORVERSION,RELEASEVERSION and BUILDVERSION (note these names apply to the delphi & c++builder actions, for VB6 or VS.NET the names would differ slightly but the technique is the same for all).

Now we can setup the properties for the ReadIni Actions.

Of course now we need a way to apply these variables to the version number properties in the compiler actions. Select the compiler action and then swich to the Script editor page and select the BeforeAction Event script, and paste in this code (this is for the Delphi action, the other compiler actions have slightly different property names) :

Action.MajorVersion = MAJORVERSION
Action.MinorVersion = MINORVERSION
Action.ReleaseVersion = RELEASEVERSION
Action.BuildVersion = BUILDVERSION

Now to save the version numbers, we need to do the reverse, using the Write Ini Action. There is one difference though, since we need to autoincrement our build number we can use the SetVariable action with the Increment modifier on the existing value (note the "Apply to Existing Value" option is checked) :

Here's how our action list looks with the read & write actions :

Of course, where and when you increment your version numbers is up to you, however FinalBuilder is extremely flexible so it's just as simple to use the registry as it is an ini file as the place to store your version numbers.

Applying the same version numbers to multiple actions

This is just more of the same thing. If you are using the built in AutoIncrement functionality then you need read the master actions version info into the variables. Add this code to the master actions (which would typically be the first compiler action in your build) AfterAction script :

MAJORVERSION = Action.MajorVersion
MINORVERSION = Action.MinorVersion
RELEASEVERSION = Action.ReleaseVersion
BUILDVERSION = Action.BuildVersion

Now we can use these variables to apply the same version numbers to as many compiler actions as we wish, using the code we showed earlier in this article.

Hopefully this article will give you some ideas to enable you to decide the best way to manage your version info in FinalBuilder.

Vincent Parrett

VSoft Technologies.

Posted in: FinalBuilder

Post Rating

Comments

There are currently no comments, be the first to post one!

Post Comment

Only registered users may post comments.