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.

dotnet pack replaces wildcard version of reference with current actual version

See original GitHub issue

Description

PackageReference with wildcard version is replaced with currently available version of referenced package in packaged nuspec file

Reproduction Steps

  • reference nuget package with wildcard version, e.g. <PackageReference Include="Some.Package" Version="1.2.*" />
  • run dotnet pack

Expected behavior

Packaged nuget mimics same semantics of wildcard version in included nuspec file (i.e, use the latest “1.2.whatever” version in the example).

Actual behavior

Wildcard version is resolved to currently matching package; this version is “hardcoded” into the nuspec file and package.

Regression?

No response

Known Workarounds

You can edit the wildcard pattern back into the packaged nuspec file, which will then produce the desired behaviour. Of course, not really a feasable thing to do in real development.

Configuration

Linux Mint 20.3 with dotnet --info:

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  2.1.818 [/usr/share/dotnet/sdk]
  5.0.404 [/usr/share/dotnet/sdk]
  6.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nkolev92commented, Jul 6, 2022

The logic is on the NuGet side, but this particular behavior is by design. Floating versions are not supported in the version element.

Documented here: https://docs.microsoft.com/en-us/nuget/reference/nuspec#dependencies-element

Enabling a floating behavior for transitive dependencies can lead to an inconsistent restore where you would be affected by changes in the feeds.

0reactions
nkolev92commented, Jul 11, 2022

Floating

Resolving lowest compatible for transitive dependency is a core behavior by NuGet. Any behavior you may get by hand editing is not guaranteed or supported.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make NuGet look for newer packages that satisfy wildcard
I'm doing the exact same thing in my project, where I want to consume the latest version of certain packages with each build, ......
Read more >
dotnet pack command - .NET CLI
The dotnet pack command creates NuGet packages for your .NET project. ... This article applies to: ✔️ .NET Core 3.1 SDK and later...
Read more >
pack command (NuGet CLI)
Applies to: package creation • Supported versions: 2.7+. Creates a NuGet package based on the specified .nuspec or project file. The dotnet ......
Read more >
I have PackageReference with wildcard, and package is not ...
When I update package manually, project file is modified, and version is replaced with newest package version. It should remain as wildcard.
Read more >
NuGet Package Version Reference
Exact details on specifying version numbers and ranges for other packages upon which a NuGet package depends, and how dependencies are ...
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