Skip to content

Add a build number to your Assembly Version

Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


TeamCity 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.

AssemblyInfo Patcher

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. TeamCity 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. TeamCity   That’s it!  After the build is complete, the assembly outputted now contains the file version with build number. TeamCity

Leave a Reply

Your email address will not be published. Required fields are marked *