Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow me to pin/lock package reference to the certain version/version range, so it's impossible to update the version via CLI or UI #14042

Open
voroninp opened this issue Jan 15, 2025 · 2 comments

Comments

@voroninp
Copy link

NuGet Product(s) Involved

dotnet.exe, Visual Studio Package Management UI, Visual Studio Package Manager Console, NuGet.exe

The Elevator Pitch

After FluentAssertions library changed their license in v8, I want to have a lock feature, so package of v7 is not upgraded to v8 accidentally.

Anyone who attempts to update the version should get the error with some message I provide to explain the reason for locking the version.

Not being able to lock the version has legal and financial implications.

Image

Additional Context and Details

No response

@jebriede
Copy link
Contributor

jebriede commented Jan 18, 2025

There are a few mechanisms that already exist that can help with this scenario.

  1. Set a version range for the package reference to constrain the version using interval notation: https://learn.microsoft.com/en-us/nuget/concepts/package-versioning?tabs=semver20sort#version-ranges
  2. Alternatively, or in addition, you can use MSBuild targets that will error if someone changes the version of the package without also manually updating the target file. Here's an example of how that can be implemented: https://github.com/NuGet/NuGet.Client/blob/313eecd3af442ee2eeed2e6decf310858934ab21/build/common.targets#L366-L370

Note that neither of these are a guarantee that the version number can't be incremented, so you'll want to rely on source control and pull request reviews to help prevent changes to the referenced package version, but they should add an additional element of protection against accidental changes. You can also consider a source control policy or action to prevent changes to a particular file unless extra approvals are provided.

Would these solutions solve the issue? If not, what other requirements would a lock mechanism in NuGet fulfill and what would be the proposed functionality?

@jebriede jebriede added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed Triage:Untriaged labels Jan 18, 2025
@voroninp
Copy link
Author

@jebriede , hm... versions range seem to work, thanks. Yet I had an impression that till recently UI will still show me the possibility of update.

Just an off-topic question:

How do I find out that new, major version update is available, if I specified a range?

I mean, when I am authoring NuGet packages I prefer to use version ranges: [x, y+1) to be explicit about what is supported. I do not like the default for fixed vrsion Version="x" which is any version >=x.

When the new version of the dependency is released, I'd like to see it and run tests to ensure my library supports it, so I can increase y further.

@microsoft-github-policy-service microsoft-github-policy-service bot added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Jan 25, 2025
@jeffkl jeffkl removed the WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants