dotnet / dotnet/project-system

Avoid downloading MSBuild SDKs from NuGet on the VS UI thread

Open
#6,069 16 comments 1 reaction 1 assignee Assigned to @melytc View on GitHub
Partner-Request-MSBuild Triage-Approved
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

The MSBuild NuGetSdkResolver may download NuGet packages during MSBuild evaluation, which can happen on the UI thread in VS. Some discussion of this: https://github.com/microsoft/msbuild/issues/4025

We are [adding some features to MSBuild SDK Resolvers](https://github.com/microsoft/msbuild/issues/5239) to support optional SDK workloads for .NET 5. This will allow SDK resolvers to:

- Return any number of SDK paths (zero, one, or many). It will be possible to return a successful result that returns no SDK paths.
- Return MSBuild items and properties to add to the evaluation result

These features will also allow us to improve the NuGetSdkResolver experience in VS. How this could work is outlined in the "NuGet SDK Resolver" section of this designs PR: https://github.com/dotnet/designs/pull/104

The proposal is this: By default, the NuGet SDK resolver would continue to work as it does today. However, in Visual Studio it would be set to a mode which would disable acquisition of the NuGet packages. In this mode, if an SDK NuGet package wasn't already available locally, the resolver would not download the package, but would add a `MissingMSBuildSDK` item with the name and version of the SDK that needs to be downloaded.

The project system would check for `MissingMSBuildSDK` items after the project is evaluated. If there are any, the project system would not load the project normally. It would launch an async acquisition process to download the NuGet packages, while showing appropriate UI (for example a spinning progress bar, or "loading..." text by the project in Solution Explorer). When the package acquisition finishes, the project system would reload the project.

We may need to add the ability for [resolvers to read global properties](https://github.com/microsoft/msbuild/issues/2095) in order for VS to communicate to the NuGetSdkResolver that it should run in this different mode.

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.