Sponsorship is available! If you’d like to sponsor CodeOpinion.com and have your product or service advertised exclusively (no AdSense) on every post, contact me.
Including the build number in your assembly version number can be a very useful feature. Using reflection you can retrieve you assembly version number and display it appropriately in your app. Here is how to add a build number to your Assembly Version using TeamCity continuous integration server
TeamCity is a continuous integration server developed by JetBrains. If you are looking at trying a new build server, I highly recommend giving it a try. It should take no longer than a hour or two to install, configure, and build your project.
There is a built-in build feature that allows you to modify the AssemblyInfo.cs during the build process. This feature works by scanning for all AssemblyInfo files (.cs, .vb, .cpp, .fs) in their usual file locations and replaces the AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion attributes with the values you define.
Add Build Feature
Under your build configuration settings, add a new Build Feature.
Select the AssemblyInfo patcher. Here you will be able to specify the version format by using parameters or static text. In my example below, I’m including the %build.counter% parameter in the version format.
That’s it! After the build is complete, the assembly outputted now contains the file version with build number.