Fix unable to update or consolidate packages due to downgrade package error Nu1605 #9224 #3553
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: Nuget/Home#9224
Regression: No
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.
For example in you have large solution with package reference style projects which are referencing each other.
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):
Consolidate error Nu1605 demo (gif animation):
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.
Downgrade works demo after change (gif animation):
Consolidate works demo after change (gif animation):
:
Testing/Validation
Tests Added: No
Reason for not adding tests:
Validation: Manual testing