Nerdbank.gitversioning: get-version and dotnet pack give different versions

Created on 4 Oct 2019  路  2Comments  路  Source: dotnet/Nerdbank.GitVersioning

I'm working with a project for which nbgv get-version shows 1.3.2, but dotnet pack produces a package with a version number of 1.3.3.

The only thing unusual about this repo is that version.json was moved a couple of commits ago:

  1. Change Foo/version.json to 1.3
  2. Move Foo/version.json to version.json
  3. Make some changes

After commit 3, get-version shows 1.3.2. I figured this was because it was tracking version.json in the repo literally. This file first appeared in commit 2, so that's 1.3.1 and the next is 1.3.2.

But packing the project in commit 3 gives a NuGet package with 1.3.3, as though it's recognizing the rename and counting from commit 1.

Whichever tracking method is used, I would expect to get the same value. Using v3.0.26.

question

Most helpful comment

I've hit this too. The reason (if they are indeed the same cause, which it sounds to be) is that when you run nbgv get-version from the root directory, its version really is 1.3.2, because it's using the current directory, whose git height for 1.3 is just 2 commits. When you run that same command from the Foo directory, you should see 1.3.3 as the version, because that directory has been at version 1.3 for one commit longer than the root directory has.

This will automatically resolve itself when you next bump the version number since that will reset the height calculation. In the meantime you can be sure to run nbgv get-version in the original directory or pass in the -p switch: nbgv get-version -p Foo.

All 2 comments

The assembly itself also has 1.3.3.

I've hit this too. The reason (if they are indeed the same cause, which it sounds to be) is that when you run nbgv get-version from the root directory, its version really is 1.3.2, because it's using the current directory, whose git height for 1.3 is just 2 commits. When you run that same command from the Foo directory, you should see 1.3.3 as the version, because that directory has been at version 1.3 for one commit longer than the root directory has.

This will automatically resolve itself when you next bump the version number since that will reset the height calculation. In the meantime you can be sure to run nbgv get-version in the original directory or pass in the -p switch: nbgv get-version -p Foo.

Was this page helpful?
0 / 5 - 0 ratings