Nerdbank.GitVersioning: The `nuget pack` command doesn't produce packages with expected version info
Quite likely that this is user error, so would appreciate any pointers.
I have a project using NB.GV 2.0.41, building with msbuild 15 from the master branch, packing using NuGet 4.3.0.
My version.json
includes:
"publicReleaseRefSpec": [
"^refs/heads/master",
"^refs/tags/v\\d+\\.\\d+"
]
My .nuspec file includes:
<version>$version$</version>
When I do nuget pack -Build
, the resulting file is just MyPackage.1.0.4.nupkg
. But NuGet gives me a warning:
WARNING: Issue: Package version not supported on legacy clients.
WARNING: Description: The package version '1.0.4+g2b37059da8' uses SemVer 2.0.0 or components of SemVer 1.0.0 that are not supported on legacy clients. This message can be ignored if the package is not intended for older clients.
WARNING: Solution: Change the package version to a SemVer 1.0.0 string. If the version contains a release label it must start with a letter.
And in fact, the embedded version string in the package does include the git commit hash.
I thought that the point of the publicReleaseRefSpec
was to prevent the git hash from appearing in the package (although it does still appear in the AssemblyInformationalVersion
is the assembly itself).
Am I misunderstanding, or doing something stupid?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (9 by maintainers)
Commits related to this issue
- Merge pull request #155 from AArnott/fixInstallSdk Fix several Install-DotNetSdk issues — committed to dotnet/Nerdbank.GitVersioning by AArnott 2 years ago
We found a workaround/solution for our build process.
nuget pack
reference there are options to pass a version intonuget pack
command which overrides the version information from the.nuspec
file. This avoids the problem that NuGet tries to resolve the package version via the AssemblyInfo.In Azure DevOps we now use
nbgv cloud --all-vars
to determine the version for the build label and the version variables. We then use aNuGetCommand@2
to perform apack
command withYou can probably also just use something like
nuget pack -Version %NBGV_NUGETPACKAGEVERSION%
or whatever is appropriate in your build system to achieve the same result. Also other version strings are available.I emailed the NuGet team to point out the issue in the docs.
I’ve never tested NB.GV with
nuget pack
. I’m not 100% confident I’ll be able to make it work well withnuget pack
– it will be conditional on how flexible it is to read various properties, and whether NB.GV can detect that that is the scenario we’re running in.I’ll leave this issue open to track nuget pack behavior.