Nerdbank.GitVersioning: Q: unable to create release version from tag
I have a version.json
file that looks like this:
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.9",
"versionHeightOffset": 2,
"publicReleaseRefSpec": [
"^refs/tags/rel/\\d+\\.\\d+\\.\\d+"
]
}
When I try to build from a tag named rel/0.9.2
I expect the nuget package to be versioned 0.9.2
, but it is versioned 0.9.9-g3ed3d4226b
.
To reproduce:
git clone https://github.com/tmds/Tmds.DBus.git
cd Tmds.DBus/
git checkout bump_092
git tag rel/0.9.2
git checkout rel/0.9.2
dotnet pack -c Release src/Tmds.DBus
It’s not clear what I’m doing wrong, or maybe I misunderstand some fields in version.json
?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (6 by maintainers)
FYI, I tried a few formats with Nerdbank.GitVersioning v3.4.255 and no “publicReleaseRefSpec”:
So, it seems impossible to get the version height in both AssemblyFileVersion and AssemblyInformationalVersion while explicitly specifying three components of the version. I did not try
"nugetPackageVersion": { "semVer": 2 }
.Thinking about it more: it would be interesting to have the version height as the 4th version digit in this case.
This can work without an additional field when the user specifies a 3-number
version
.Maybe some part of .NET tooling would have issues with the 4-number version?
As this github issue is getting long, and it appears that questions have been answered and no bug identified, I’ll close the issue. If I missed something and there is actually an outstanding issue, please let me know and we can re-open. Or, if the issue was identified halfway through the discussion, just open a new issue to track. 😉
Okay, this is a bit of a late reply since I have had bigger things on my plate until just now(ish) but I had been able to test this in Azure DevOps. With the environment variables in place GitVersioning was able to pick up on the correct tag name structure and ditch the
-dev
suffix. I was confused since I thought that it pokes at git directly, rather than only relying on environment variables from CI. Thank you for making me aware of that difference.https://github.com/dotnet/Nerdbank.GitVersioning/blob/0e7febc2b1cee560376eb53ea962f4eb47ed69ff/src/NerdBank.GitVersioning/VersionOracle.cs#L105-L109
It has a single
this.BuildingRef
string and tries to match that to each regex listed inthis.VersionOptions.PublicReleaseRefSpec
.BuildingRef
comes fromhttps://github.com/dotnet/Nerdbank.GitVersioning/blob/0e7febc2b1cee560376eb53ea962f4eb47ed69ff/src/NerdBank.GitVersioning/VersionOracle.cs#L63
git checkout tag makes HEAD point to the same commit as the tag; it does not save the name of the tag (except perhaps in a reflog). There could be any number of tags pointing to the same commit and Nerdbank.GitVersioning won’t try to guess. However you can provide the tag name via various “cloud build” environment variables; search for
BuildingTag
in the sources.