update assembly version on git commit in Visual Studio

Viewed 2259

I am facing a nightmate of keeping track of not one, but 5 applications that regularly update and work together in tandem.

On each update, I must manually update AssemblyInfo.cs file with incremental version. Also, I store each version in git so I need to add a tag or commit message of current assembly version. This is super error prone, because I need to remember to modify assembly version on 2 location.

I'd like to connect this 2 operations together, so that on every commit or merge with production branch, assmebly version in AssemblyInfo.cs is updated/incremeneted and commit message/tag is set to current assembly version.

What is the best way to achieve this workflow? I am interested in both Visual Studio and Rider IDE.

1 Answers

You could use something like GitVersion. GitVersion allows you to specify a version via commit tags, or will update SemVer for you based on a variety of factors, and allows you to write the versions, generated or otherwise, to all Assembly Info files. The specific usage will depend somewhat on your project structure. I specifically use it as part of a build pipeline with Azure Devops, but it was worked well for us so far.

Related