We have a system which consists of numerous applications. All applications have their version changed at the same time. Currently, when we release a new version, we have to manually open the project options of each application and change the version one by one. Is there any way to compile all applications on the same version, for example, save it in a global file and upon compilation, read this file and assign that version to the project? I’m just trying to eliminate too many steps, because we plan on changing the version numbers more frequently. I’d like to change it in one place only. Can this be done? and how?
We have a system which consists of numerous applications. All applications have their version
Share
You can create a
VERSIONINFOresource, in a plain text file (eg.,Versioninfo.rc)Note: The C-style null terminators (
\0) are needed at the end of each item as shown in order for the resource compiler to properly terminate the strings. Otherwise, when you use Explorer to display the version information for the executable you may get garbled or partially concatenated values.Add a line to your project source file:
I suggest putting the common version info resource into an externals reference in your version control system, and then you can just check it out into each project’s folder and update it easily.
Do a Project->Build, and your version info is embedded in the .exe. You can verify by using Windows Explorer and viewing the properties of your app.
There’s a couple of posts (one by me and one in a response by Jim Fleming) in the Embarcadero Delphi forums at CodeNewsFast archives. Mine is [here], where, I describe step-by-step how to use a pre-build event in your project to update the version number in the resource script I posted above.
Jim posts a few replies, but about a dozen posts or so down there’s source for an executable that can be called from the pre-build event that works for him. (There are some things I’d do differently, like letting the IDE pass the project name and location on the command line; how to do so is described in the step-by-step article. I’d also handle the version parsing and incrementing differently, but the basic app is a good starting location.)
Embarcadero’s groups are currently down, but I was able to retrieve Jim’s code from CodeNewsFast as well, and can reproduce it here:
A) Create your Version Info resource file in your project directory or wherever, with the following
contents, and file extension .rc:
B) Create a new project in some folder, code of only module should be similar to:
C) In Project Options of the project whose build number should be incremented:
Remove the tick “include version info”.
Add a pre-build event with the following text, as written, including the two pairs of double-quotes, substituting the parts within < >:
“<full file name and path of the auto-increment program exe>” “<full file name and path of the .rc resource file>”
D) Add to the project source, right below the “program” keyword:
be the same here: IIRC, got errors when they were different.
E) Compile, run and enjoy the return of Auto-Increment build numbers, despite Embarcadero’s having removed the facility.
You could use the pre-build event to, for instance, update the
ProductNameorFileDescriptionvalues, or any others that have to be different from the base script.