question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The `nuget pack` command doesn't produce packages with expected version info

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
michael-xcommented, Jul 23, 2019

We found a workaround/solution for our build process.

  1. According to the cloud build documentation there are options to have NB.GV emit variables containing the proper version strings.
  2. According to the nuget pack reference there are options to pass a version into nuget 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 a NuGetCommand@2 to perform a pack command with

  • versioningScheme: byEnvVar
  • versionEnvVar: NBGV_NUGETPACKAGEVERSION

You 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.

1reaction
AArnottcommented, Nov 27, 2017

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 with nuget 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The `nuget pack` command doesn't produce packages with ...
I have a project using NB.GV 2.0.41, building with msbuild 15 from the master branch, packing using NuGet 4.3.0. ... When I do...
Read more >
dotnet pack command does not generate .nuget packages ...
We have a solution with mutiple projects that includes projects with unit and spec tests. When we run dotnet pack command on the...
Read more >
pack command (NuGet CLI)
Creates a NuGet package based on the specified .nuspec or project file. The dotnet pack command (see dotnet Commands) and msbuild -t:pack ...
Read more >
Unable to resolve dependencies of NuGet packages
Solution · Clear the NuGet cache files. You do this in the following way: In the toolbar of Visual Studio, navigate to Tools...
Read more >
NuGet packages in the Package Registry
When asking for versions of a given NuGet package name, the GitLab Package Registry returns a maximum of 300 most recent versions. Do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found