dotnet / dotnet/project-system

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

Open
#1,600 1 comment 1 reaction 1 assignee Claimed by @davkean View on GitHub
Feature-NuGet Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

This is a more specific version of https://github.com/dotnet/roslyn-project-system/issues/1332 and believe to be a cause of https://github.com/NuGet/Home/issues/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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.