Found a simple way to automatically increment the build number of .NET assemblies.
You need a program which will parse the AssemblyInfo.cs file and pick up the build number from there, increment and write back the file.
You'll need to call this program as part of your Pre Build step.
The program is a small C++ utility which does all the parsing and stuff. Its also not very intelligent, it can handle only versions specified as:
[assembly: AssemblyVersion("1.0.3.0")]
In the pre-build event command line, enter:
..\..\..\..\tools\IncBuildNumber.exe $(ProjectDir)Properties\AssemblyInfo.cs -build
This is for my project which has a directory structure like this:
Logman
|
- Tools
|
-Source
|
- Sid.Utilities
The Tools folder contains IncBuildNumber.exe
The Source\Sid.Utilities contains my C# project.
Note, for older .NET project, the AssemblyInfo.cs will not be under Project\Properties folder, it will be directly under the Project folder.
Last point, when building from the IDE, do not keep the AssemblyInfo.cs file open since this will cause the IDE to ask for reloading the file.
Here is the
source code for the utility.
Here is a
link to download the utility.