Introduction
Here, I'm going to explain a simple mechanism which will help you to add version information for the build done in Visual Studio. The main advantage of this approach is it provides the flexibility of controlling the version update format by simply modifying the source provided by this article.
Once you modify the provided code and configure it accordingly, it will do the version update automatically.
Background
I have gone through a few articles and decide to implement something very simple that will automate version number management. As a result, I have used a simple header with #define
directive that contains version data. This header is created by our simple application and updates the last digit and writes back new version data to the same header.
This version data header is accessed by resource file(.rc) at the post build event and used for version generation.
Using the Code
- Add a header file named VersionNo.h into directory represented by
$(InputDir)
macro.

File should contains the following two entries:
#define FILEVER 2,0,0,5
#define PRODUCTVER 2,0,0,0
- Create a resource file in your Visual Studio project at the directory represented by
$(InputDir)
and add the following script to the file if it doesn't exist or modify it to be like that.
#include "VersionNo.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION FILEVER
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Sample Application\0"
VALUE "CompanyName", "Microsoft Corp.\0"
VALUE "FileDescription", "MyProject Application\0"
VALUE "FileVersion", FILEVER
VALUE "InternalName", "MyProject\0"
VALUE "LegalCopyright", "Copyright (C) 2010\0"
VALUE "OriginalFilename", "MyProject.EXE\0"
VALUE "ProductName", "MyProject Application\0"
VALUE "ProductVersion", PRODUCTVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
- Now compile your
myExe
project and copy the output (.exe) to the same directory as above. - Finally, right click your project and goto Build Events -> Post-Build Event and in Command Line input box, add the following line.
"$(InputDir)"\myExe.exe
Now compile your project and right click on your output and go to Details tab to see the result.

Points of Interest
MyExe
project is a simple project that reads a given file and rewrites the same thing back with some modifications (by increasing the last digit of version number). You can extend this to write a suitable version update controller that matches your requirements by having some knowledge in C++.
History
- 27th August, 2010: Initial post