dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

An error `It was not possible to find any installed .NET SDKs.` causes focus to move to Output window constantly #4199

Open justinmchase opened 3 years ago

justinmchase commented 3 years ago

I keep getting this error at an interval, I've spent way to long scanning through old bugs and trying things out. The plugin appears to be working fine and everything is building yet OmniSharp keeps emitting this error.

It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download

When this happens it changes focus from the terminal to the Output window. The fact that this is building correctly makes me think it's an error with omnisharp specifically, I have set the $MSBuildSDKsPath to the correct path, before I did that building wasn't working either, now building works but omnisharp (semi-)doesn't.

export MSBuildSDKsPath="/usr/local/Cellar/dotnet/$(dotnet --version)/libexec/sdk/$(dotnet --version)/Sdks"
15:41:07:jchase24:~/code$ ls -la $MSBuildSDKsPath
total 0
drwxr-xr-x   12 jchase24  MS\Domain Users   384 Sep 30 08:59 .
drwxr-xr-x  130 jchase24  MS\Domain Users  4160 Sep 30 08:59 ..
drwxr-xr-x    3 jchase24  MS\Domain Users    96 Sep 30 08:59 FSharp.NET.Sdk
drwxr-xr-x    5 jchase24  MS\Domain Users   160 Sep 30 08:59 ILLink.Tasks
drwxr-xr-x    3 jchase24  MS\Domain Users    96 Sep 30 08:59 Microsoft.Docker.Sdk
drwxr-xr-x    6 jchase24  MS\Domain Users   192 Sep 30 08:59 Microsoft.NET.Sdk
drwxr-xr-x    6 jchase24  MS\Domain Users   192 Sep 30 08:59 Microsoft.NET.Sdk.Publish
drwxr-xr-x   10 jchase24  MS\Domain Users   320 Sep 30 08:59 Microsoft.NET.Sdk.Razor
drwxr-xr-x    5 jchase24  MS\Domain Users   160 Sep 30 08:59 Microsoft.NET.Sdk.Web
drwxr-xr-x    5 jchase24  MS\Domain Users   160 Sep 30 08:59 Microsoft.NET.Sdk.Web.ProjectSystem
drwxr-xr-x    5 jchase24  MS\Domain Users   160 Sep 30 08:59 Microsoft.NET.Sdk.Worker
drwxr-xr-x    5 jchase24  MS\Domain Users   160 Sep 30 08:59 NuGet.Build.Tasks.Pack

Environment data

dotnet --info output:

14:55:37:jchase24:~/code$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.109
 Commit:    32ced2d411

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/Cellar/dotnet/3.1.109/libexec/sdk/3.1.109/

Host (useful for support):
  Version: 3.1.9
  Commit:  a5bf06c9d4

.NET Core SDKs installed:
  3.1.109 [/usr/local/Cellar/dotnet/3.1.109/libexec/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.9 [/usr/local/Cellar/dotnet/3.1.109/libexec/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.9 [/usr/local/Cellar/dotnet/3.1.109/libexec/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

VS Code version:

15:30:49:jchase24:~/code$ code --version
1.51.0
fcac248b077b55bae4ba5bab613fd6e9156c2f0c
x64

C# Extension version:

v1.23.5

OmniSharp log

This is with log level: critical set:

Starting OmniSharp server at 11/10/2020, 2:55:41 PM
    Target: /Users/jchase24/code/cashops-api/CashopsApi.sln

OmniSharp server started.
    Path: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/run
    PID: 79349

It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download

With level:trace set here is some additional logs which may be helpful:

...
MSBuild environment: 
Mode: Standalone
RunningTests: False
RunningInVisualStudio: False
MSBuildToolsDirectory32: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
MSBuildToolsDirectory64: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
MSBuildSDKsPath: /usr/local/Cellar/dotnet/3.1.109/libexec/sdk/3.1.109/Sdks
CurrentMSBuildConfigurationFile: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/MSBuild.exe.config
CurrentMSBuildExePath: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/MSBuild.exe
CurrentMSBuildToolsDirectory: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
VisualStudioInstallRootDirectory: 
MSBuildExtensionsPath: /Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
...
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.resources, Version=15.1.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        FAILURE: Could not locate '/Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Microsoft.Build.resources.dll'.
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
...

Steps to reproduce

Just opening visual studio code with a C# project in the opened folder produces this issue.

Expected behavior

  1. I expect this info to not be logged more than 1 time:
    It was not possible to find any installed .NET SDKs.
    Install a .NET SDK from:
    https://aka.ms/dotnet-download
  2. I expect this information to not be logged at all when log level critical is set
  3. I expect logging this information to not cause focus to shift to the Output panel

Actual behavior

The error is displayed many times, each time it occurs focus is stolen from where you are typing and it switches to the output panel (true of the terminal panel at least).

justinmchase commented 3 years ago

When I look for this file:

/Users/jchase24/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Microsoft.Build.resources.dll

Which it says it cannot find, the file does in fact not exist. The file Microsoft.build.dll does however exist in that same directory. I guess my question is, so what? Why should it generate a critical level log to output for a file which doesn't appear to be actually necessary, especially one with so little signal and a seemingly misleading message.

JoeRobich commented 3 years ago

@justinmchase Sorry you are running into issues with SDK resolving. It is a frustrating issue.

The failure logging for Microsoft.Build.resources.dll is not a real problem. To keep the size of the included MSBuild down, we do not include localization. This is reported as a failure because it probes for resources as part of assembly loading, but this does not change or break the behavior of MSBuild.

Because the SDKs were not installed with the official installers, it is possible there is some bit of environment setup breaking your experience. You could try enabling the LegacySdkResolver (see these instructions https://github.com/OmniSharp/omnisharp-roslyn/issues/1313#issuecomment-429039879) to see if that fixes your experience. If that does indeed resolve things for you, the omnisharp.json file can be moved to your home directory and will apply system wide.

justinmchase commented 3 years ago

I did try the LegacySdkResolver but it doesn't seem to fix it... And really its working fine its just that it keeps stealing focus. I don't care if it prints this stuff out it just needs to stop taking focus away. Every time I switch branches or change a file it seems to take focus away from my terminal and other panels.

I think that this line is a bug: https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/observers/OmnisharpChannelObserver.ts#L16

Again, I think its fine that its printing this information out but I really don't think anything it can possibly print out warrants focus stealing.