Tech Support > Microsoft Windows > Drivers > RE: I need tips on how to update my file version number automatically, please.
RE: I need tips on how to update my file version number automatically, please.
Posted by Nadav on April 1st, 2004


Concerning you have a dedicated file for your version and you include it in all of your .rc files, the file should look as follows:

Version.h
#define MY_VERSION 8,90,0,7
#define STR_MY_VERSION "8.90.0.7"

The .rc file version section should look as follows:

MyProj.rc
....
#include "..\Version.h"
....
....
VS_VERSION_INFO VERSIONINFO
....
BEGIN
...
VALUE "FileVersion", STR_MY_VERSION
...
VALUE "ProductVersion", STR_MY_VERSION
END




After doing all of the above you can create a small .bat file that will update the Version.h file with the corresponding build number and build your project, following is an example:
( Concerning the IDE you are using is VS.NET )

BuildProj.bat:
**********
del /F /Q Version.* > _Junk.tmp
@echo Updating Version.h...
@echo #define MY_VERSION %1.%2.%3.%4 > ver01.tmp
@echo #define STR_MY_VERSION "%1,%2,%3,%4" > ver02.tmp
@copy /B ver01.tmp + ver02.tmp Version.h > Junk.tmp
@del *.tmp > Junk.tmp


@echo About to start the build process.
@echo Building 'Debug' version....
"%VS71COMNTOOLS%..\IDE\devenv.exe" MyProject.sln /clean Debug
"%VS71COMNTOOLS%..\IDE\devenv.exe" MyProject.sln /rebuild Debug
@echo Building 'Release' version....
"%VS71COMNTOOLS%..\IDE\devenv.exe" MyProject.sln /clean Release
"%VS71COMNTOOLS%..\IDE\devenv.exe" MyProject.sln /rebuild Release
@echo Build process finished.

Syntax Sample:
BuildProj 1 0 0 5 <- this will build the project and will set a version of 1.0.0.5 to all of it's dlls.
NOTE: Each of the projects being compiled should include the same Version.h in it's .rc file.

Hope this helps,
Nadav.

Posted by Walter Oney on April 1st, 2004


Nadav wrote:
You solved everything except the OP's original question: how does he get
the build number to automatically *update* every time he does a build?
Besides which, why not use the ">>" operator instead of creating two
files that you then glue together?

--
Walter Oney, Consulting and Training
Basic and Advanced Driver Programming Seminars
Check out our schedule at http://www.oneysoft.com