1

Given I have some C# and C++ libraries in a GIT repository and I have a "Development" branch from which all feature and bug fix branches are derived.

How can I make it so that when a developer merges their feature/bug-fix branch into "Development" then pushes it (to ensure they have first pulled the latest version information from other developers), they are prompted for each library they have made a change to, to specify how they would like the assembly version incremented for its project (e.g. "What type of change was this? Major, Minor, Build or Revision"). The new version information should then ideally auto-commit prior to the push happening.

I am doing this so that changes cannot be made to an assembly and that assembly released to a customer without the version number having been changed from a previous release. I also want to avoid using the * syntax in Visual Studio for Build and Revision components so that there are not huge unexplained gaps in the numbers.

If a developer merges their branch into Development than once, I am happy for the version number to change or stay the same.

Specifically the attributes I want to change in the C# assemblies are under AssemblyInfo.cs and are:

  • [assembly: AssemblyVersion("0.0.0.0")]
  • [assembly: AssemblyFileVersion("0.0.0.0")]

In C++ it would be the .rc version file added to the project via Add → Resource → Version → New.

Matt Arnold
  • 668
  • 2
  • 8
  • 21
  • Take a look at https://www.nuget.org/packages/Nerdbank.GitVersioning maybe it can fit your requirements. – Alexey Rumyantsev Apr 08 '21 at 14:58
  • If you have a continuous integration setup, you can add a script that checks for that. Otherwise, git provides hooks, which allow you to execute scripts e.g. before pushing, however, this can quickly get confusing especially if your script is buggy, prefer a continuous integration check. – asynts Apr 08 '21 at 15:09
  • Unfortunately we don't have a continuous integration setup. The hooks would be what I'm looking for. I do already have a console application I've used a lot for changing assembly version numbers of all projects in a given folder or solution so I'd use that for the C# version incrementation; however, I would need to write some code for the source control analysis side of things. – Matt Arnold Apr 09 '21 at 11:36
  • 1
    Just dropping a link to a good resource: [Pro Git: Customizing Git - Git Hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). I'd generally recommend that book for any git related stuff. – asynts Apr 10 '21 at 16:04

0 Answers0