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

[DCR]: Allow floating versions with Central Package Management (CPM) #10432

Closed
BamButz opened this issue Jan 7, 2021 · 19 comments · Fixed by NuGet/NuGet.Client#5440 or NuGet/NuGet.Client#5528
Assignees
Labels
Area:RestoreCPM Central package management Functionality:Restore Priority:2 Issues for the current backlog. Type:DCR Design Change Request
Milestone

Comments

@BamButz
Copy link

BamButz commented Jan 7, 2021

Details about Problem

We use CPVM to manage our dependencies. Unfortunately, the last update presented us with a big problem. With the introduction of NU1011, it is no longer possible for us to run a resolution strategy that selects the highest possible version. This is especially relevant for our in-house dependencies, as we distribute regular patches and this can no longer be done automatically.

Suggested things

Our suggestion is to implement a switch that deactivates the validation of NU1011. We understood the problem that led to the implementation of NU1011, but can rule out the problem for us.

@dominoFire dominoFire added Area:RestoreCPM Central package management Type:Bug labels Jan 20, 2021
@aortiz-msft aortiz-msft added the Type:DCR Design Change Request label Jan 21, 2021
@aortiz-msft
Copy link
Contributor

Thank you for your feedback! We are evaluating all the feedback provided for the preview release of CPVM to understand how we can improve the design for its final release in an upcoming version of .NET.

@glennawatson
Copy link

@jeffkl jeffkl changed the title Floating versions using CPVM [DCR]: Floating versions using CPVM Apr 15, 2022
@jeffkl jeffkl removed the Type:Bug label Apr 15, 2022
@jeffkl jeffkl self-assigned this Apr 15, 2022
@JonDouglas JonDouglas added the Priority:2 Issues for the current backlog. label Apr 19, 2022
@voroninp
Copy link

voroninp commented Nov 15, 2022

@BamButz ,

We understood the problem that led to the implementation of NU1011,

Could you explain, please?
I'm still scratching my head in attempts to understand why this limitation was introduced.

@BamButz
Copy link
Author

BamButz commented Nov 15, 2022

I'm afraid I'm not really into the topic anymore, but you can read up on this issue.

@elpht
Copy link

elpht commented Jan 9, 2023

Won't this be a candidate for next Central Package Management improvements epics?

@handerss-spotfire
Copy link

This feature would be great, it would allow us to switch from the MSBuild version of central package versions which does support this.

@ds1709
Copy link

ds1709 commented Mar 1, 2023

We are using SonarAnalyzer.CSharp in our projects. To be sure we are using the latest version, in package reference version is 8.*. Becase floating versions are not supported, we cant move to CPMV yet.

@jeffkl jeffkl added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Pipeline:Icebox and removed Priority:2 Issues for the current backlog. labels Aug 17, 2023
@jeffkl
Copy link
Contributor

jeffkl commented Aug 18, 2023

We have updated the documentation to explain more about the decision to not have CPM support floating versions.

https://learn.microsoft.com/nuget/reference/errors-and-warnings/nu1011

@handerss-spotfire
Copy link

@jeffkl An example of a "enterprise-level" use-case for floating versions is internally published NuGet packages. In our use-case for example we publish internal packages with semantic version numbers which match across different projects and then bump the prerelease tag, or the 4th number in the version. The prerelease tag can also be made to match specific branch identifiers. This means we publish new versions of internal packages dozens of times per day (for a larger enterprise this could of course be hundreds of times per day). Having a commit for each such bump would make the commit log very noisy.

Perhaps floating package versions could be added with a more explicit way of opting in? E.g. via a flag in the csproj (this way it would be easy to disallow floating versions for builds being built in release configurations).

@jeffkl
Copy link
Contributor

jeffkl commented Aug 21, 2023

@handerss-tibco that's an interesting example. Does your organization ever experience issues with that set up? For example, does a bad package get pushed and it breaks everything because everyone downstream automatically consumes it? It seems really risky and non-deterministic, especially since NuGet has an HTTP cache. There is no example that a package that was just pushed will be consumed (unless you're clearing the HTTP cache constantly). Do you ever find that different machines end up with different versions of dependencies?

Perhaps floating package versions could be added with a more explicit way of opting in?

I'm definitely considering this possibility. I'm still trying to determine if it sets people up for success. One of the things I worry about is your organization hires a new employee. That person's interaction with NuGet might be rocky based on your work process and they might blame NuGet as a product for the constant breakage and non-determinism when its not a recommended scenario.

@glennawatson
Copy link

@jeffkl this scenario also comes up a bit on the reactiveui open source project. We have internal packages we push we rely on from other repo we just want to rely on latest.

@jeffkl
Copy link
Contributor

jeffkl commented Aug 21, 2023

@glennawatson okay thanks for chiming in. Are you okay with the fact that based on NuGet's HTTP cache, there's no guarantee that any give machine is actually using the "latest"? And that if any of the packages are bad, you have to push a fixed package and wait for the HTTP cache to expire/manually clear it before things are working again? Essentially, are you okay with such non-determinism and no ability to roll back to a known good state?

@glennawatson
Copy link

In this scenario yes.

@handerss-spotfire
Copy link

handerss-spotfire commented Aug 22, 2023

@jeffkl It seems we're indeed clearing the HTTP cache for package listings which use floating versions, which I don't think is ideal. In our scenario it would be preferred if there was a guarantee that the latest package is used, however I realize that cannot be achieved without negatively affecting build times.

A better solution would be if there was a CLI command which performs this style of update. I believe this is achieved in npm for example via npm-update which updates according to constraints specified in package.json (similar to Directory.Packages.props). In other package managers this can usually be achieved by removing the lock file.

@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. and removed Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Triage:NeedsTriageDiscussion Pipeline:Icebox labels Sep 25, 2023
@jeffkl
Copy link
Contributor

jeffkl commented Sep 25, 2023

I'm going to explore adding a feature flag to enable floating versions in central package management which the user would have to opt into. There are some concerns that it would be wholly incompatible with transitive pinning which I'll look into.

@bkoelman
Copy link

The lack of floating version support in CPM is an adoption blocker for my project as well, and the guidance to use dependabot instead isn't an option.

My team builds a public NuGet package that depends on EF Core. In the project file, we have pinned the Microsoft.EntityFrameworkCore dependency to a specific version, which we can only update in the next major release. But at the same time, we want to run our test suite against the latest patch version, so we'll know when something breaks. Therefore we need to use a floating version of Microsoft.EntityFrameworkCore in tests. If supported, we'd define the floating version in Directory.Packages.props (for tests, benchmarks, examples), then use VersionOverride in the library project to pin.

Dependabot is unable to deal with this. It's only possible to exclude a package globally, not per project. So we had to exclude Microsoft.EntityFrameworkCore from scanning.

The package caching is not a concern for us, because our GitHub Actions runners that verify the build quality always start clean.

@jeffkl
Copy link
Contributor

jeffkl commented Oct 11, 2023

Just an FYI to everyone involved in this issue, we'll be adding an option to enable floating versions for CPM in the next release. It will still be off by default but a user can enable it going forward. NuGet/NuGet.Client#5440

@nkolev92 nkolev92 added this to the 6.9 milestone Oct 19, 2023
@jeffkl
Copy link
Contributor

jeffkl commented Nov 20, 2023

Reopening as this was reverted, I am working on making it pass our insertion criteria

@jeffkl jeffkl reopened this Nov 20, 2023
@jeffkl jeffkl changed the title [DCR]: Floating versions using CPVM [DCR]: Allow floating versions with Central Package Management (CPM) Dec 13, 2023
@JeffYoungHRB
Copy link

This is preventing our adoption as well.
Many of our internal packages contain things like an enumeration that we add to and want every consumer of the package to get the latest on build. The only way I can see doing that without a flag is adding to the ado build pipeline to unlist the prior versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:RestoreCPM Central package management Functionality:Restore Priority:2 Issues for the current backlog. Type:DCR Design Change Request
Projects
None yet