Auto Increment the Version Number after Each Build in a Visual Studio Project

Overview

As you know, Windows Executable Binary Files (EXE, DLL, and so forth) have their own version information.
This information consists of four positions with two bytes each, such as “xx.xx.xxxxx.xx” (it means major.minor.buildno.extend).
Already, there are several standalone tools or VS macros to implement automatic version numbering. But, these were not enough to implement more dynamic version numbering.

So finally, I tried to make a version number build tool myself to support more enhanced functions and to be more useful.
This tool, ‘VERBUILD ‘ will help you manage a rather more complex version numbering system more easily.

Features

  • Increments the version number on each build.
  • Supports two types of build numbers (daily basis and normal digits).
  • Supports overflow shifting.
  • Maximum and minimum positions are available.
  • An individual increment option is available for file version or product version.
  • There is an option to add a null string to the string version.
  • The method creates ‘VersionNo.h’ and uses .rc2/.

Options

Sample code

VERBUILD file   <format>  [options...]
VERBUILD @file [<format>] [options...]
  • file: Version header file to update. The @file list file switch specifies one file on each line for example:
  • c:\project1\versionno.h
    c:\project2\versionno.h=*.*.*.+
    
  • <format>: x.x.x.x specifies the version number changes. x is one of following:
    • *: Keep current position + : increment position by one
    • digits: Set position to this value. for example, *.*.71.+
  • -l: The specified list files
  • -d<baseyear>: Daily basis mode. Increments by date indexing from base year, as in -d2005
  • -x<fFpP>: f,F: (F)ile version that it uses to increment.
    • p or P: (P)roduct version to increment on.
    • f,p (individual increment): F,P (set by full version).
  • -b<format>: Sets minimum version value for beginning.
  • -e<format>: Sets maximum version value for ending. The format is xx.xx.xxxxx.xx, where each digit’s length is a free size. for example, -e15.10.99999.20 -e200.99.1000.300 -b1.0.0.0
  • -s: Overflow shift is turned on
  • -n[buildno]: Verify daily basis build number and convert to date/time. for example, if the version number is 15.0.2304.26, to verify 2304 you would use verbuild -n2304 -d2005. The result is ‘2007-11-01’.
  • -u: Adds a null to the string version.
  • -c: Checks file existence and creates it if it does not exist.
  • -t[delay]: No update if not reached in [delay] seconds. The default is 5 seconds. use -t0 for no delay.
  • -r[ymd]: Sets a term to reset extend positions in daily basis. every (y)ear,(m)onth or (d)ay. eg. -ry for annually.(updated)
  • -v: Verbose
  • -h or -?: For more detailed help, use your VS.NET VS2005 Project!

Examples

Each version’s positions consists of major.minor.buildno.extend and simply to A.B.C.D,

  • verbuild VersionNo.h -c: Creates an initial VersionNo.h file if it does not exist already.
  • verbuild VersionNo.h *.*.*.+ -d2005 -xFp -b1.0.0.0 -e10.10.2310.12 -s: The daily basis from 2005(-d2005), minimum buildno position is 1.0.0.0(-b), and the maximum build number is 10.10.2310.12(-e). only increasing the part ‘D’ positions of the A.B.C.D Format(*.*.*.+), the file version is equal to the full version(-xF). the product version is individually self increasing (-xp). If it is in the overflow minimum or maximum positions, shifts each positions of A.B.C.D(-s) but,in daily basis mode,the part ‘C’ positions is fixed by daily information. When ‘D’ positions are overflowing,’B’ will be increased by skip ‘C’ if in daily basis mode.
  • verbuild VersionNo.h *.*.*.+ -xFp -b1.0.0.0 -e10.10.2310.12 -s: Normal build number positions mode (part ‘C’ positions) are in effect.
  • verbuild -n2303 -d2005: Decodes the build number (part ‘C’ positions) created by daily basis mode with the -d option.

More by Author

Must Read