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

Add option to override transitive dependency versions when managing packages centrally #4025

Merged

Conversation

marcin-krystianc
Copy link
Contributor

@marcin-krystianc marcin-krystianc commented Apr 28, 2021

Bug

Fixes: NuGet/Home#10389
Fixes: NuGet/Home#10327

Regression? Last working version: 5.8 (feature removed in v5.9)

Description

This PR reverts the change that disabled the transitive dependency pinning feature. Additionally it is being now made optionable, so it will be possible to use CPVM (Central Package Version Management) with transitive dependency pinning or without it.

Project can opt-in for transitive dependency pinning by defining property:

    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>

PR Checklist

@marcin-krystianc
Copy link
Contributor Author

ping

@stackedsax
Copy link

@aortiz-msft any chance you'll be able to look at this one? I noticed @zivkan assigned this to you to look at some time back. Seems like the feature would be to the community's benefit.

@marcin-krystianc
Copy link
Contributor Author

Recent comments on the NuGet/Home#6764 show, that there is a demand for this feature to be brought back.
It is important for us to get it in before .NET 6 release, otherwise we are going to be stuck with .NET 3.1 (which is the last version in which it was available).
What can we do to help reviewing it?

@stackedsax
Copy link

stackedsax commented Jul 5, 2021

Yeah, maybe 20+ comments in the past week and lots more thumbs up to many of those comments. Seems like there's plenty of community interest in getting this feature back in. @aortiz-msft, @zivkan, anything more we can do to help push this one along?

@aortiz-msft aortiz-msft assigned nkolev92 and unassigned aortiz-msft Jul 8, 2021
@jjmanton
Copy link

@marcin-krystianc @nkolev92 Is this PR still under review? We would very much like to pin transitive dependencies

@stackedsax
Copy link

@jjmanton we'd certainly like it still be under review. @nkolev92, are you able to take a look and give us some feedback? We'll look for a different assignee if you are unavailable. Thanks!

@stackedsax
Copy link

@aortiz-msft , you were on the original #3719 issue -- do you have any thoughts here?

@zivkan, you've offered some good feedback for some of our other PR's in NuGet.Client -- is there anyone else we should direct this PR to?

@rconard, @cristinamanum, any thoughts here?

Any and all comments would be appreciated -- we'd just like to keep the conversation on this one moving!

@avivanoff
Copy link

There is quite some activity on the NuGet/Home#10389. This feature is definitely needed, and is quite critical for us.

@lazy8
Copy link

lazy8 commented Sep 8, 2021

Hi @nkolev92 is there still a chance for this PR to get accepted? Is there something anybody else could/should do? My company (and others too apparently) are pretty much stuck with nuget 5.8 (and respective dotnet version 5.0.1XX) until this gets re-enabled/fixed.

@lazy8
Copy link

lazy8 commented Sep 21, 2021

Hello @nkolev92, could you please review this merge request? Or assign it to somebody who can? Thanks.

@stackedsax
Copy link

@nkolev92 There a couple of us who would love some sort of signal on this one. We'd love this to be included .NET 6, and we're worried that it will miss that deadline.

@zivkan, any input on this one?

@martincostello
Copy link

As an external observer, with them already having shipped RC1 and the bar for inclusion being higher and higher for RC2 and GA, realistically I think the ship has already sailed on this being part of .NET 6.

@stackedsax
Copy link

As an external observer, with them already having shipped RC1 and the bar for inclusion being higher and higher for RC2 and GA, realistically I think the ship has already sailed on this being part of .NET 6.

Yup, but I must keep the sliver of hope alive!

More importantly, I'd just like to get some eyes on this so that it lands at some point. It looks like there are plenty of people who want this feature back.

@batzen
Copy link

batzen commented Sep 23, 2021

@martincostello Transitive version pinning was removed in a minor patch version in .NET 5, so i don't think there is even a bar. The group which was invited and supposed to test and give feedback on CPVM wasn't even asked before it was suddenly removed.
The docs the expert panel group gave feedback on still state:

Transitive Dependencies
If any packages are imported as transitive dependencies from a <PackageReference> where the Version is controlled by a <PackageVersion> in Directory.Packages.props, then the version of the transitive dependency will be controlled by CPVM.

FYI: That's a quote from https://aka.ms/CentralNuGetLearningDocs

And https://github.com/NuGet/Home/wiki/Centrally-managing-NuGet-package-versions also says:

Transitive dependencies: The versions for the packages defined in the Directory.Packages.props will win for direct and transitive dependency resolution.

So currently CPVM does not behave as described in all docs available.

@rconard Why do we still have to wait for this PR to be merged? Not being able to define versions for transitive dependencies in CPVM causes issues all the time and we have to add direct dependencies to projects that don't require direct dependencies.

@batzen
Copy link

batzen commented Sep 24, 2021

@aortiz-msft Russel said you might be able to help here as he moved to Azure IoT.

@lazy8
Copy link

lazy8 commented Oct 2, 2021

@aortiz-msft Russel said you might be able to help here as he moved to Azure IoT.

Hello @aortiz-msft, @nkolev92,
another week had passed without any kind of reaction (Plenty of other activities though).
Makes it now 157 days in total.
Really not sure what to make of this.

@stackedsax
Copy link

Just wanted to note that @JonDouglas did comment on the associated issue last week:

Hopefully, this is a good sign!

@marcin-krystianc
Copy link
Contributor Author

Given that vast majority of votes is in favour of transitive dependency pinning being enabled by default, I'm going to update my branch to reflect that:

image

Are there any other concerns or requests for this features which are not reflected in my PR yet?

@JonDouglas
Copy link
Contributor

Hey @marcin-krystianc,

We're finalizing a longer-term plan for this feature going into the new year(I owe the other thread an update). If you would like to take the time to reflect the recent consensus, please feel free but keep in mind that we're still planning to have a team member review the PR in-depth when they finish up with existing commitments. Thank you!

@JonDouglas
Copy link
Contributor

JonDouglas commented Nov 16, 2021

Hi all,

We recently published a small document/proposal that includes a few thoughts around this behavior & some questions that would further help us move this feature forward. If would mean a lot if you can provide your feedback in the PR itself:

#11391

Thanks!

@nkolev92 nkolev92 assigned jeffkl and unassigned nkolev92 Jan 11, 2022
@marcin-krystianc marcin-krystianc force-pushed the dev-marcink-20210428-transitivepinning branch from 6a88650 to 8d4cf6d Compare February 28, 2022 12:51
…ransitivepinning

# Conflicts:
#	src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs
#	src/NuGet.Clients/NuGet.SolutionRestoreManager/VSNominationUtilities.cs
#	src/NuGet.Clients/NuGet.SolutionRestoreManager/VsSolutionRestoreService.cs
#	src/NuGet.Core/NuGet.Build.Tasks.Console/MSBuildStaticGraphRestore.cs
#	src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets
#	src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/MSBuildRestoreUtility.cs
#	src/NuGet.Core/NuGet.Common/PublicAPI/net45/PublicAPI.Unshipped.txt
#	src/NuGet.Core/NuGet.Common/PublicAPI/net472/PublicAPI.Unshipped.txt
#	src/NuGet.Core/NuGet.Common/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
#	src/NuGet.Core/NuGet.ProjectModel/JsonPackageSpecReader.cs
#	src/NuGet.Core/NuGet.ProjectModel/PackageSpecWriter.cs
#	src/NuGet.Core/NuGet.ProjectModel/ProjectRestoreMetadata.cs
#	src/NuGet.Core/NuGet.ProjectModel/PublicAPI.Unshipped.txt
#	test/NuGet.Core.Tests/NuGet.Commands.Test/MSBuildRestoreUtilityTests.cs
@marcin-krystianc marcin-krystianc force-pushed the dev-marcink-20210428-transitivepinning branch from 05001df to 0d98d88 Compare March 1, 2022 16:02
@jeffkl jeffkl changed the title CPVM - Resurrect the "transitive dependency pinning" feature and make it optionable Add option to override transitive dependency versions when managing packages centrally Mar 1, 2022
@jeffkl jeffkl marked this pull request as ready for review March 1, 2022 19:56
Copy link
Contributor

@jeffkl jeffkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution. Overall this looks great and has good test coverage, just minor comments. Let's get feedback on the property name and I think we're good.

src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets Outdated Show resolved Hide resolved
Comment on lines 342 to 343
if (packageSpec.RestoreMetadata?.CentralPackageVersionsEnabled == true &&
packageSpec.RestoreMetadata?.TransitiveDependencyPinningEnabled == true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get rid of these old comparisons to true

Suggested change
if (packageSpec.RestoreMetadata?.CentralPackageVersionsEnabled == true &&
packageSpec.RestoreMetadata?.TransitiveDependencyPinningEnabled == true)
if (packageSpec.RestoreMetadata?.CentralPackageVersionsEnabled &&
packageSpec.RestoreMetadata?.TransitiveDependencyPinningEnabled)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both terms are nullable so the comparison to true is rather necessary.

@jeffkl
Copy link
Contributor

jeffkl commented Mar 1, 2022

@NuGet/nuget-client this PR is now ready for review. Please leave your feedback on the property name we'll use to enable the feature.

Copy link
Contributor Author

@marcin-krystianc marcin-krystianc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffkl Thanks for your review, I've responded to all suggested changes. so It is ready for another review.

Comment on lines 342 to 343
if (packageSpec.RestoreMetadata?.CentralPackageVersionsEnabled == true &&
packageSpec.RestoreMetadata?.TransitiveDependencyPinningEnabled == true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both terms are nullable so the comparison to true is rather necessary.

src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets Outdated Show resolved Hide resolved
Copy link
Contributor

@jeffkl jeffkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the contribution!

Copy link
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hard work @marcin-krystianc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PRs created by someone not in the NuGet team
Projects
None yet