Open davkean opened 7 years ago
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.
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:
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.