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

PM UI: Consolidate or Update packages operations should not be blocked due to errors (Package Downgrade, etc.) #9224

Closed
bondarenkod opened this issue Feb 26, 2020 · 4 comments
Assignees
Labels
Functionality:VisualStudioUI Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Style:PackageReference Type:DCR Design Change Request

Comments

@bondarenkod
Copy link

bondarenkod commented Feb 26, 2020

Please read the following information before posting the issue.

Details about Problem

NuGet product used: VS UI
NuGet package manager: 5.4.0
VS version: VS 16.4.5
OS version: win10 (18363.657):
Worked before?: NO

Detailed repro steps so we can see the same problem

  1. Solution with multiple projects. Some of the projects included different versions of some packages. Some projects are referenced by others. For example PkgA(1.0, 1.1), PkgB(2.0, 2.1), PkgC(3.0, 3.1).
    image

  2. I want to consolidate or update versions of these packages to the latest (or single) one. But while I'm trying to do any of these actions, the process usually stopped by the next two errors:

  • Error NU1605 Detected package downgrade: PACKAGE_NAME from X.X.X.X to Y.Y.Y.Y. Reference the package directly from the project to select a different version.
  • Error NU1107 Version conflict detected for PACKAGE_NAME. (rarely)
    But it's exactly I want to do - update all these packages!
    image

Other suggested things

I think the update or consolidate process should be fixed, and all these errors should be ignored during these operations. It should do what I want and warn\show errors after all.

Also, I can probably suppress these errors by adding NU1107, NU1605 to NO_WARN section, but I don't want to leave these suppressions there forever.

Verbose Logs

no logs

Sample Project

I don't have the sample project now, I can't share the private project, I will try to create an example later.

#8982

Fix details: In PMUI downgrade or consolidate.

Currently Nu1605 single largest cause of nuget install to fail according to below graph, after this fix is pushed this will drop very significantly, I expect it'll go down on-par to NU1202, even less than NU1202.
image

For example in you have large solution with package reference style projects which are referencing each other.

image

ConsoleApp2(grandparent)=> ConsoleApp1(parent)=>MainApplication(child)

Now if you downgrade children and parent same time to same version or consolidate many different versions into same not highest version then it throws Nu1605 error. But still downgrade one bottom child, but not others. To finish it you have to repeat this action one by one.

Downgrade error Nu1605 demo (gif animation):
DowngradeNU1065error

Consolidate error Nu1605 demo (gif animation):

ConsolidateNU1065error

If you 30 projects and they have different versions of same package then you may need to try up to 30 times to downgrade or consolidate all of them.
With my change only 1 time try it will succeed if input are good or fail depending if input are not good.
Now we're doing smart restore let children restore first then cache needed restore result in memory, next we restore parent and parent's of parent in target group in correct order so it wouldn't fail.
Current change doesn't change this current behavior: If you only select child ( without selecting parent too) and update to higher version than parent then it'll succeed, but wouldn't build code later.
Also good thing is it doesn't update half of solution and create any undesirable state. This change will help with my next fix #6010 to make it more deterministic and instead of bubbling many times of repeated restore only 1 time pass will work.
Please review @nkolev92 @zivkan @rrelyea, I tried to make as minimal surgical change without affecting other logics, for that one I took time to understand how whole process works. Here is my PR#3553.

Downgrade works demo after change (gif animation):
DowngradeFixed

Consolidate works demo after change (gif animation):
ConsolidateFixed
:

@nkolev92
Copy link
Member

nkolev92 commented Mar 3, 2020

Hey @bondarenkod
Thanks for filing this issue

I think the update or consolidate process should be fixed, and all these errors should be ignored during these operations. It should do what I want and warn\show errors after all.

Am I interpreting this correctly to mean Do not validate whether an install/uninstall/update operation is successful, just write it in the project file

@nkolev92 nkolev92 added the WaitingForCustomer Applied when a NuGet triage person needs more info from the OP label Mar 3, 2020
@bondarenkod
Copy link
Author

One more example.
Here is the scheme and short overview why it happening to me:
image
When I'm working from the Solution B with core projects, I'm updating packages.
When I'm switching to the Solution A, I have different versions of packages in the Solution A's projects.

Packages in the current example:

  • Microsoft.AppCenter family, including the *.Crashes, *.Distribute and *.Analytics NuGet packages.
  • PI.XamarinForms.Core - private package (without any dependencies to Microsoft.AppCenter.*)

The initial state of the Consolidate NuGet Packages window:
image

Detailed view for the PI.XamarinForms.Core package:
image
But after pressing install a see the next errors in the errors list window:
image
So, I’m not able to update this package.

Let’s move to update window:
image
After pressing install I see the same error.

I also tried to update Microsoft.AppCenter.* packages:
image

The result the same, but now you can see more errors related to the PI.XamarinForms.Core package:
image

It looks like when the NuGet tries to update packages it sees other packages downgrade status and it's kind of blocker for the current update process - circular dependency.

I have no auto workarounds for this except the only one - manually change the package version in the *.csproj file.

@nkolev92 thank you for your response! Yep, something like that. I think the NuGet should just do update and ignore some types of errors - e.g. 'detected package downgrade'.

@nkolev92 nkolev92 added the Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. label Jul 2, 2020
@nkolev92
Copy link
Member

nkolev92 commented Jul 8, 2020

Hey @bondarenkod.

So based on what you are describing, I think it's similar to #6010.

Can you try to manually update all package versions on disk and run a restore?
Does it work then?
If yes, then I believe #6010 will help fix your scenario.

@erdembayar
Copy link
Contributor

erdembayar commented Sep 3, 2020

Merged the fix this morning.
It was made as part of another performance improvement work: NuGet/NuGet.Client#3559

@erdembayar erdembayar changed the title vs: unable to consolidate or update packaged due to Detected package downgrade error vs: unable to consolidate or update packaged due to Detected package downgrade error Nu1605 Sep 3, 2020
@rrelyea rrelyea added the Type:DCR Design Change Request label Oct 28, 2020
@rrelyea rrelyea changed the title vs: unable to consolidate or update packaged due to Detected package downgrade error Nu1605 vs: consolidate or update packages should not be blocked due to resulting errors (Detected package downgrade error Nu1605, etc..) Oct 28, 2020
@dominoFire dominoFire changed the title vs: consolidate or update packages should not be blocked due to resulting errors (Detected package downgrade error Nu1605, etc..) PM UI: Consolidate or Update packages operations should not be blocked due to errors (Package Downgrade, etc.) Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:VisualStudioUI Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Style:PackageReference Type:DCR Design Change Request
Projects
None yet
7 participants