dotnet / vscode-csharp

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

can't find SDKs on MacOSX #4698

Open micahasmith opened 3 years ago

micahasmith commented 3 years ago

Issue Description

Can't get a .net core project to work on macosx-- here's the terminal output.

Starting OmniSharp server at 8/9/2021, 3:30:26 PM
    Target: /Users/micahsmith/dev/cs

OmniSharp server started.
    Path: /Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/run
    PID: 43679

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 11.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 17.0.0 - "/Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 17.0.0 - "/Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin
            CscToolPath = /Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /Users/micahsmith/.vscode/extensions/ms-dotnettools.csharp-1.23.14/.omnisharp/1.37.14/omnisharp/.msbuild
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/micahsmith/dev/cs'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/Users/micahsmith/dev/cs'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/micahsmith/dev/cs/cs.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/micahsmith/dev/cs'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/micahsmith/dev/cs' on host 34369.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/micahsmith/dev/cs/cs.csproj
It was not possible to find any installed .NET SDKs.
Install a .NET SDK from:
  https://aka.ms/dotnet-download
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file '/Users/micahsmith/dev/cs/cs.csproj'.
/Users/micahsmith/dev/cs/cs.csproj(0,0)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  /Users/micahsmith/dev/cs/cs.csproj
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult, System.Boolean throwOnFileNotExistsError) [0x0032a] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x00027] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate () [0x0013b] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCacheBase projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext, System.Boolean interactive) [0x00047] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00063] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00035] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.Initialize (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00127] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00073] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <e78286a6f9b047bca66ad86e9b031ef5>:0 
  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath, System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] projectConfigurationsInSolution) [0x00160] in <123e9399922f43fb93d71bfa60dd04d6>:0 
  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath, System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] configurationsInSolution) [0x0000d] in <123e9399922f43fb93d71bfa60dd04d6>:0 
  at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectIdInfo projectIdInfo, OmniSharp.MSBuild.ProjectLoader loader, System.Guid sessionId, OmniSharp.Services.DotNetInfo dotNetInfo) [0x00023] in <123e9399922f43fb93d71bfa60dd04d6>:0 
  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass31_0.<LoadProject>b__0 () [0x00000] in <123e9399922f43fb93d71bfa60dd04d6>:0 
  at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult()
  at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loader) [0x0001b] in <123e9399922f43fb93d71bfa60dd04d6>:0 

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /Users/micahsmith/dev/cs/cs.csproj

Steps to Reproduce

Expected Behavior

Actual Behavior

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.59.0 C# Extension: 1.23.14

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.205 Commit: 64a0cf25eb Runtime Environment: OS Name: Mac OS X OS Version: 11.4 OS Platform: Darwin RID: osx.11.0-x64 Base Path: /usr/local/Cellar/dotnet/5.0.205/libexec/sdk/5.0.205/ Host (useful for support): Version: 5.0.8 Commit: 42ac4d6d5a .NET SDKs installed: 5.0.205 [/usr/local/Cellar/dotnet/5.0.205/libexec/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 5.0.8 [/usr/local/Cellar/dotnet/5.0.205/libexec/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.8 [/usr/local/Cellar/dotnet/5.0.205/libexec/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |calva|betterthantomorrow|2.0.208| |copilot|GitHub|1.3.2283| |csharp|ms-dotnettools|1.23.14| |dart-code|Dart-Code|3.25.1| |flutter|Dart-Code|3.25.0| |jupyter|ms-toolsai|2021.8.1195043623| |paperclip-vscode|crcn|17.14.7| |prettier-vscode|esbenp|8.1.0| |python|ms-python|2021.8.1105858891| |remote-containers|ms-vscode-remote|0.191.0| |remote-kubernetes|Okteto|0.3.3| |remote-ssh|ms-vscode-remote|0.65.7| |remote-ssh-edit|ms-vscode-remote|0.65.7| |synthwave-vscode|RobbOwen|0.1.8| |vscode-docker|ms-azuretools|1.15.0| |vscode-mysql|formulahendry|0.4.1| |vscode-pull-request-github|GitHub|0.29.0| |vscode-pylance|ms-python|2021.8.0| |vscodeintellicode|VisualStudioExptTeam|1.2.14| |vsliveshare|ms-vsliveshare|1.0.4673|;
JoeRobich commented 3 years ago

This is likely a similar scenario as Snap installs of the SDK. I would recommend you use the official installer (https://dotnet.microsoft.com/download/dotnet/5.0) or try this fix for Snap installs (https://github.com/OmniSharp/omnisharp-vscode/wiki/Configuring-Snap-installs-of-dotnet-sdk.) with the path updated to match the Cellar install path.

micahasmith commented 3 years ago

I tried the official installer-- same issue.

JoeRobich commented 3 years ago

@micahasmith Can you share the new output of dotnet --info?

micahasmith commented 3 years ago
➜  5.0.201 dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.302
 Commit:    c005824e35

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/5.0.302/

Host (useful for support):
  Version: 5.0.8
  Commit:  35964c9215

.NET SDKs installed:
  3.1.411 [/usr/local/share/dotnet/sdk]
  5.0.201 [/usr/local/share/dotnet/sdk]
  5.0.302 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
➜  5.0.201
micahasmith commented 3 years ago

btw I tried setting SDKPath but it didn't pick it up

nmsmith22389 commented 3 years ago

I'm having the exact same problem. Works in ZSH but VSCode doesn't pick it up.

aaronmbos commented 3 years ago

I'm running into the same issue. Can run everything dotnet related from the terminal, but nothing dotnet related in VS Code via OmniSharp extension.

ghidalgo3 commented 3 years ago

I'm also running into the same issue, and this is the second time that OmniSharp inexplicably in VSCode. I will no longer recommend anyone use VSCode to develop C#, this instability is unacceptable.

ghidalgo3 commented 3 years ago

Had to uninstall and reinstall OmniSharp to fix this problem, but I also ended up installing every single version of the .NET 6 Preview SDK to see if it fixed the issue. Who knows what was really the problem...