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

In .xproj project.json, make sure a package is uninstalled before installing #823

Merged
merged 1 commit into from Aug 15, 2016

Conversation

joelverhagen
Copy link
Member

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 using Update-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 using Update-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

@joelverhagen
Copy link
Member Author

/cc @emgarten @rohit21agrawal @alpaix @abpiskunov

🔔


if (packageToReplace != null)
{
await UninstallPackageAsync(packageToReplace.PackageIdentity, nuGetProjectContext, token);
Copy link
Contributor

Choose a reason for hiding this comment

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

what function is called into when we update from updates tab?
is there a way we can make the codepath for update from update tab same as the update from any other place? this would ensure we don't have to change behavior in different places in the future...

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a possibility, but given that this ProjkectKNuGetProject (.xproj) implementation is going away soon, I opted to not refactor the other two NuGet project types for a problem specific to .xproj.

Choose a reason for hiding this comment

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

I Assume that this UninstallPackage would keep state key that you send to InstallPackage below via args? If yes then lgtm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. The UninstallPackageAsync is the exact same method that is invoked when during a batch update or an explicit uninstall.

@rohit21agrawal
Copy link
Contributor

LGTM otherwise.

@emgarten
Copy link
Member

:shipit:

1 similar comment
@abpiskunov
Copy link

:shipit:

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