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

Prefer updating only the conditioned packages when updating in VS and dotnet add package #5420

Merged
merged 10 commits into from
Sep 26, 2023

Conversation

nkolev92
Copy link
Member

@nkolev92 nkolev92 commented Sep 22, 2023

Bug

Fixes: https://github.com/NuGet/Client.Engineering/issues/2237

Covers large parts of NuGet/Home#4681 - due to the urgency of this fix, I'll validate all scenarios in that issues have been addressed afterwards and I'll have any follow up fixes if needed.

Regression? Last working version:

Description

Note that this started as a larger change, so I had written up a spec on this, however as I was implementing it and adding tests I discovered the accidental bug introduced in 4.4! You can read more in depth in #5420, but it should not be necessary to review this PR.

For a conditionally installed PackageReference, NuGet does not update conditional reference correctly consistenly. Currently all updates of conditional packages lead to attempting to install the package to all frameworks, thus often causing an NU1504 warning. The change here is for the update gesture to update a package only in the frameworks it's installed in.

Note that this behavior appears to be a regression of f9569ac.
I verified that 1.1.14 of .NET SDK does not have the problem at hand. It is extremely likely that Visual Studio did not have the same issues for updating, but very likely had issues where no-op was constantly incorrect after a package installation.

The preview step boils down to a call to PackageSpecOperation.AddOrUpdate(..).
In f9569ac, the AddOrUpdate call was changed to always add to all framework. That was done because the AddOrUpdate without frameworks did not update the correct list for PackageReference based projects.
PackageReference based projects always use the TargetFrameworkInformation object dependency list.
The correct fix is to update the original AddOrUpdate without frameworks method to account for PackageReference based projects.

  • The AddPackageReferenceCommandRunner changes affect dotnet add package.
  • The NuGetPackageManager changes affect PM UI & PMC.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

@nkolev92 nkolev92 changed the title Fix conditional updating in VS and dotnet add package Prefer updating only the conditioned packages when updating in VS and dotnet add package Sep 22, 2023
@nkolev92 nkolev92 marked this pull request as ready for review September 23, 2023 00:06
@nkolev92 nkolev92 requested a review from a team as a code owner September 23, 2023 00:06
@nkolev92 nkolev92 merged commit fed7892 into dev Sep 26, 2023
@nkolev92 nkolev92 deleted the dev-nkolev92-fixConditionalUpdate branch September 26, 2023 00:59
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Sep 26, 2023

I have reviewed the changes and about to click approve but noticed that PR has been merged. The proposed changes look good👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants