Get current assembly version of your Umbraco website

At work we use TeamCity as a part of our Continuous Deployment procedure for all of our Umbraco websites (even Umbraco Cloud) and one build step I find particularly useful is the one that we call: Update AssemblyInfo Version.

This step checks the current release tag and sets the AssemblyInfo.cs version accordingly. For example if we have a release branch called release/5.2.x with the highest tag being 5.2.1 then TeamCity will set the assembly version as such:

[assembly: AssemblyVersion("")]

Why do we set this version number?

There’s a lot of reasons for setting this assembly version but one use case in particular is when our QA managers are testing our applications and are reporting bugs.

Some bugs might only occur in a specific version of an application so our QA managers always adds the version number in the bug report so that the developers know where to start troubleshooting.

And when we’ve fixed the bug, we need to patch that release and then it’s useful to have the version number documented in the bug report.

Exposing the version number:

So how do our QA managers know which version they’ve found a bug in? We don’t really want them to be digging around in the source or open up Kudo, there’s to much risk involved in that.

So what we usually do in our Umbraco projects is we expose an API endpoint that returns the current version in a JSON object:

This way our QA managers can either curl this endpoint:

Or simply just call if from their browser, like so:

This object can be extended if needed with other useful information, for instance last commit hash, datetime of last deploy etc.

If you want to extend it with information that could be considered sensitive use the UmbracoAuthorizedApiController or UmbracoAuthorizedJsonController to make sure the QA managers will have to be logged in to Umbraco to be able to call this endpoint.


The only downside with this approach, as discussed on Twitter, is that this endpoint only works if the site runs. If for some reason Umbraco cannot be booted correctly this endpoint will not respond. But I guess this isn't much of a problem since if the site is down that would be a high priority issue and developers will look in the source and not use an endpoint.

Anyway hope it can be useful to someone.
Cheers friends!❤️