dotnet / dotnet/roslyn

MSBuildWorkspace reports incomprehensible error when required SDK not found

Open
#80,466 0 comments 0 reactions 1 assignee Claimed by @jasonmalinowski View on GitHub
Area-IDE
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

Reproduction steps

1. Create a C# project with a global.json referencing a .NET SDK that is not installed.
2. Open the workspace in VSCode with the C# extension standalone
3. Note the project loading error

Expected:
Reports an error referencing the .NET SDK required by the global.json that is not installed

Actual:
Incomprehensible error with no further output
```
2025-09-25 16:40:58.671 [error] [project/open] [LanguageServerProjectLoader] Error while loading c:\Users\dabarbet\source\repos\trash\ConsoleAppGlobalJson\ConsoleAppGlobalJson.csproj: Exception thrown: Microsoft.CodeAnalysis.MSBuild.RemoteInvocationException: An exception of type System.InvalidOperationException was thrown: Failed to find all versions of .NET Core MSBuild. Call to hostfxr_resolve_sdk2. There may be more details in stderr.
at Microsoft.CodeAnalysis.MSBuild.RpcClient.InvokeCoreAsync(Int32 targetObject, String methodName, List`1 parameters, Type expectedReturnType, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/Rpc/RpcClient.cs:line 186
at Microsoft.CodeAnalysis.MSBuild.RpcClient.InvokeNullableAsync[T](Int32 targetObject, String methodName, List`1 parameters, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/Rpc/RpcClient.cs:line 129
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.g__NoLock_GetBuildHostAsync|15_0(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, String dotnetPath, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs:line 138
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, String dotnetPath, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs:line 97
at Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager.GetBuildHostWithFallbackAsync(BuildHostProcessKind buildHostKind, String projectOrSolutionFilePath, CancellationToken cancellationToken) in /_/src/Workspaces/MSBuild/Core/MSBuild/BuildHostProcessManager.cs:line 68
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.TryLoadProjectInMSBuildHostAsync(BuildHostProcessManager buildHostProcessManager, String projectPath, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 90
at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectLoader.ReloadProjectAsync(ProjectToLoad projectToLoad, ToastErrorReporter toastErrorReporter, BuildHostProcessManager buildHostProcessManager, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectLoader.cs:line 229
```

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.