In .xproj project.json, make sure a package is uninstalled before installing #823
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.
This is for NuGet/Home#3303.
When updating a package in a .xproj project.json we want to maintain state in that dependency node. For example, if a dependency has
"target": "project"
, this should not be lost during an update of that dependency. This works today when using the Updates tab in the VS UI or when usingUpdate-Package
PMC command. However, when pressing the Update button under the Installed or Browse tabs, this state is lost. The root cause of this is that the user's update action only registers as an "install" operation. When usingUpdate-Package
, both an "uninstall" and "install" occur.This is only a problem for .xproj project.json because UWP project.json merges an install of an already installed package into the existing project.json.
The fix is to uninstall before installing. This will then allow the update state to be populated and used on the subsequent install.
One problem I noticed while testing this that the Browse and Updates tabs don't always have the result of an install/update immediately visible. In other words, the user presses install/update, NuGet executes the install/update, then the UI refreshes, showing the state prior to the install/update. This is because the project.json restores happen asynchronously. Since this is a pre-existing issue with install, I decided not to address it.
/cc @emgarten @rohit21agrawal @alpaix @abpiskunov