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

Cannot install/query NuGet packages immediately after a project has loaded #1600

Open
davkean opened this issue Feb 23, 2017 · 1 comment
Open
Assignees
Labels
Feature-NuGet NuGet integration including pushing it properties, project and package references, and Pack support. Triage-Approved Reviewed and prioritized
Milestone

Comments

@davkean
Copy link
Member

davkean commented Feb 23, 2017

This is a more specific version of #1332 and believe to be a cause of NuGet/Home#4622.

Installing a package just after a project has loaded, is resulting in:

The operation failed as details for project Web1 could not be loaded.System.InvalidOperationException: The operation failed as details for project Web1 could not be loaded.
at NuGet.PackageManagement.VisualStudio.CpsPackageReferenceProject.GetAssetsFilePathAsync()
[..] Async logic
at NuGet.VisualStudio.VsPackageInstaller.InstallPackage(String source, Project project, String packageId, String version, Boolean ignoreDependencies)
at Microsoft.VisualStudio.Azure.Fabric.Shared.ServiceCreation.ServiceTemplateInterpreter.InstallNuGetPackages(IServiceProvider serviceProvider, Hierarchy project, ServiceTemplateServiceContentProjectPackage[] packages, String serviceId)Failed to install package 'Microsoft.ServiceFabric.Data':

This is because we haven't nominated for restore before our project factory has completed. At the moment, it's running after the factory has completed and after a design-time build has been completed. Instead, we consider doing this much earlier before we've been added to the solution and during evaluation. Make note that if we do this - NuGet might not be able to get specific information until the project has fully loaded.

Whatever we do here, is that once the factory has been completed, you should be able to install a package.

@aleksander-oven
Copy link

I find that this is still a problem in VS 2017.9. I have a VSIX that implements a wizard. The wizard tries to install a NuGet package inside its RunFinished method. This used to work fine with the old COM-based project system (i.e. using flavored project type), but fails after transitioning to CPS. My current workaround is to call Task.Run + Task.Delay before calling IVsPackageInstaller's methods. It gets things done, but feels really hacky.

@jmarolf jmarolf closed this as completed Dec 6, 2018
@jmarolf jmarolf reopened this Dec 6, 2018
@jjmew jjmew modified the milestones: 16.0, 16.X Feb 13, 2019
@jjmew jjmew added the Triage-Approved Reviewed and prioritized label Jul 21, 2020
@jjmew jjmew added this to the 16.x milestone Jul 21, 2020
@drewnoakes drewnoakes modified the milestones: 16.x, 17.x Oct 6, 2021
@drewnoakes drewnoakes removed the Bug label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-NuGet NuGet integration including pushing it properties, project and package references, and Pack support. Triage-Approved Reviewed and prioritized
Projects
None yet
Development

No branches or pull requests

8 participants