A few years ago we moved to git from svn at the start of a new project. We had a lot of devs going. We also had several QA involved, and there was a lot of code being churned out quickly.  Different branches were undergoing QA and UAT at once, so it could take a few minutes to track down the specific version that was deployed.

So What Did We Decide to Do?

We decided to start using the git hash, (git rev-parse head) to tag the assemblies. This was, in addition, to using the standard branch-build number combination. At the beginning of the development process, we found that using the commit hash was more reliable than using branches or tags. This was especially so while the build environments were being changed frequently. Since then, having this piece of information living along with your code provides additional peace of mind.

In the first iteration, we simply wrote the information into some text files; the solution we’re providing here is a much better approach:

1. Link a GlobalAssemblyInfo.cs file to your assemblies, containing some standard parameters:

using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyCompany("Greenfinch Technology")]
[assembly: AssemblyCopyright("Greenfinch Technology 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyConfiguration("Release")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("")]
[assembly: AssemblyFileVersion("git-hash-here")]
[assembly: AssemblyInformationalVersion("build-job-here")]

Since the Assembly Version is left alone, writing these properties will not break compatibility between assemblies. This means you can continue to use whatever strategy you like. Visual Studio will generate warnings about using these during the build process and unfortunately ignores attempts at suppressing them.

You can add more AssemblyInfo files to contain things like assembly names, GUIDs etc. if you need.

2. During the CI process, we set two parameters using powershell:


# Jump up one directory up from where the script file is located
Push-Location ((Split-Path $MyInvocation.MyCommand.Path) + '\..')

function UpdateDevInfo([string]$fileLocation)
    $githash = [string](git rev-parse HEAD)

    $content = (get-content $fileLocation)

    $content = ForEach-Object {
        $content -replace "AssemblyFileVersion`\(`"[^`"]+'`\)","AssemblyFileVersion(`"$githash`")"

    $content = ForEach-Object {
        $content -replace "AssemblyInformationalVersion`\(`"[^']+`"`\)","AssemblyInformationalVersion(`"$version`")"

    Set-Content $fileLocation $content



Assembly provides methods for retrieving the strings in the application. The linker time stamp can similarly be retrieved. We also found it useful to dump the full set of information into all log files on application startup. This helps to track version changes when going back through the logs.


A Final Word

At Greenfinch Technology we are always actively working to keep up with modern technology. In our opinion. to stand still is to fall behind. You can be sure we have no intention of letting that happen to ourselves or to our clients.

If you would like a modern, forward-thinking IT company to help with your custom enterprise software solutions mobile app development, a BPM such as Siskin or any Cloud technologies please feel free to contact us at 01 818 2949 or email us using our contact form. We will help guide you safely through the process of advancing your company beyond your competitors.

Greenfinch Technology

Greenfinch Technology