Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ho do I prevent GitVersion from including the commit hash in the version number?

I've just started using GitVersion in TFS 2018.3 (VSTS, Azure DevOps), and really trying the easy option. I use the GitVersion TFS marketplace task straight out of the box. I tagged the master branch with 1.1.0.0 and ran the build.

The build log shows:

2018-10-25T15:39:53.1843138Z INFO [10/25/18 17:39:53:08] Updating assembly info files 2018-10-25T15:39:53.1843138Z INFO [10/25/18 17:39:53:18] Found 42 files 2018-10-25T15:39:53.3123172Z [section]Async Command Start: Update Build Number 2018-10-25T15:39:53.3123172Z Update build number to 1.2.0-alpha.354-20181025.1 for build 1107

From that, I would expect a version 1.2.0-alpha.354-20181025.1 but the resulting version in AssemblyInformationalVersion is:

<Assembly: AssemblyInformationalVersion("1.2.0-alpha.354+Branch.develop.Sha.1b44044f1e3324182b9e1f37958b6a4942731e59")>

or

<Assembly: AssemblyInformationalVersion("1.2.0-some_branch_name.1+366.Branch.feature/some_branch_name.Sha.1b44044f1e3324182b9e1f37958b6a4942731e59")>

Is there a way to prevent displaying the Branch.develop.Sha.1b...?

Is this the right way to use that task?

like image 868
reckface Avatar asked Oct 19 '25 14:10

reckface


1 Answers

To customize the default settings of GitVersion you should add a GitVersion.yml file in the root of your repository. For example with these contents:

mode: ContinuousDeployment
assembly-informational-format: '{SemVer}-{CommitDate}'
branches: {}
ignore:
  sha: []

This will result in a version string of 1.2.0-alpha.354-2018-10-25.

To try if your GitVersion.yml file works correctly, you could open up a command line and execute GitVersion.exe /updateassemblyinfo. This works only if you've installed GitVersion locally, e.g. with choco install GitVersion.Portable. See also GitVersion docs. However executing the GitVersion.exe /updateassemblyinfo command will provide you with a full list of variables available for you to include in your GitVersion.yml file.

like image 65
Herman Cordes Avatar answered Oct 21 '25 03:10

Herman Cordes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!