Auto-Incrementing Build Numbers in Visual Studio.NET
Every Windows executable binary file (EXE, DLL, etc) has a version consisting of the following elements and format: Major.Minor.Build.Revision. To many software users, this is just a random string of numbers. For those that develop and deploy software though, this version information is important, even crucial in troubleshooting situations. Have you ever wondered how the version is controlled or set, and how you can manage the version in your own Visual Studio projects?
Visual Studio provides a default algorithm for building and assigning assembly version information when compiling an assembly. While the default algorithm does not automatically increment the major and minor elements of the version, it can increment the build and revision elements. The build element reflects the number of days since January 1, 2000 and the revision element reflects the number of seconds since midnight divided by two (2). To enable auto-versioning within Visual Studio, follow these simple steps for a C# project (VB projects follow identical steps with slightly different formatting).
- Open the file AssemblyInfo.cs
- Change [assembly: AssemblyVersion("1.0.0.0")] to [assembly: AssemblyVersion("1.0.*")]
- Remove [assembly: AssemblyFileVersion("1.0.0.0")]
- Rebuild the project and verify that the version is incremented properly by viewing the properties of the newly compiled assembly
Incrementing versions is a wise choice to provide traceability through multiple published versions of code. If you find that just tracking to the build and revision is not sufficient for your needs, it is also possible to leverage other aspects of Visual Studio in order to implement custom auto-incrementing algorithms. If you’re having trouble getting auto-versioning setup for your development projects, contact us to see if we can help. If you’re an expert at this sort of thing and have additional tips and tricks to share, please leave us a comment.
Tags: development, Microsoft, programming, Revision Control, version control, Visual Studio.NET
Read more posts by Paul Luc


