vscode-csharp: Omnisharp can't find .NET SDK when open any C sharp project
Whenever I open any C sharp project no matter via VS code icon or terminal, it shows such error
It was not possible to find any .NET SDKs.
I am pretty sure I have SDK installed
I have tried to follow the wiki . Reinstall C sharp extension, reinstall SDK, reboot computer, export the /usr/local/share/dotnet/dotnet
in ~/.bashrc
, ~/.profile
, ~/.zshrc
. None of them work.
Environment data
dotnet --info
output:
.NET Core SDK (reflecting any global.json):
Version: 3.1.401
Commit: 39d17847db
Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.401/
Host (useful for support): Version: 3.1.7 Commit: fcfdef8d6b
.NET Core SDKs installed: 3.1.401 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
VS Code version: Version: 1.48.2
C# Extension version: v1.23.2
OmniSharp log
Starting OmniSharp server at 9/3/2020, 5:44:56 PM Target: /Users/jimmy/Desktop/cSharp
OmniSharp server started. Path: /Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/run PID: 1287
Starting OmniSharp on MacOS 10.15.6 (x64)
DotNetPath set to dotnet
Located 1 MSBuild instance(s)
1: StandAlone 16.8.0 - "/Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/omnisharp/.msbuild/Current/Bin"
MSBUILD_EXE_PATH environment variable set to '/Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
Registered MSBuild instance: StandAlone 16.8.0 - "/Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/omnisharp/.msbuild/Current/Bin
CscToolPath = /Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /Users/jimmy/.vscode/extensions/ms-dotnettools.csharp-1.23.2/.omnisharp/1.37.1/omnisharp/.msbuild
Detecting Cake files in '/Users/jimmy/Desktop/cSharp'.
Could not find any Cake files
No solution files found in '/Users/jimmy/Desktop/cSharp'
Queue project update for '/Users/jimmy/Desktop/cSharp/cSharp.csproj'
Detecting CSX files in '/Users/jimmy/Desktop/cSharp'.
Could not find any CSX files
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
Loading project: /Users/jimmy/Desktop/cSharp/cSharp.csproj
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
Configuration finished.
Omnisharp server running using Stdio at location '/Users/jimmy/Desktop/cSharp' on host 1262.
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/jimmy/Desktop/cSharp/cSharp.csproj’.
/Users/jimmy/Desktop/cSharp/cSharp.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK ‘Microsoft.NET.Sdk’ specified could not be found. /Users/jimmy/Desktop/cSharp/cSharp.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <4322d44f99c84aab9075efd37869f964>: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 <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Evaluator4[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) [0x00309] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x00027] in <4322d44f99c84aab9075efd37869f964>:0 at Microsoft.Build.Evaluation.Evaluator
4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <4322d44f99c84aab9075efd37869f964>:0 at Microsoft.Build.Evaluation.Evaluator
4[P,I,M,D].Evaluate () [0x0013c] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Evaluator4[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.PropertyDictionary1[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 <4322d44f99c84aab9075efd37869f964>: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 <4322d44f99c84aab9075efd37869f964>: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 <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.Initialize (System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00127] in <4322d44f99c84aab9075efd37869f964>: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 <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Project…ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <4322d44f99c84aab9075efd37869f964>: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 <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.Project…ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <4322d44f99c84aab9075efd37869f964>:0 at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary
2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <4322d44f99c84aab9075efd37869f964>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <4322d44f99c84aab9075efd37869f964>:0
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath, System.Collections.Generic.IReadOnlyDictionary2[TKey,TValue] projectConfigurationsInSolution) [0x00160] in <7e6cb753aca94549b693616e0e7d1016>:0 at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath, System.Collections.Generic.IReadOnlyDictionary
2[TKey,TValue] configurationsInSolution) [0x0000d] in <7e6cb753aca94549b693616e0e7d1016>: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 <7e6cb753aca94549b693616e0e7d1016>:0
at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass31_0.<LoadProject>b__0 () [0x00000] in <7e6cb753aca94549b693616e0e7d1016>:0
at (wrapper delegate-invoke) System.Func1[System.ValueTuple
3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray1[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 <7e6cb753aca94549b693616e0e7d1016>:0
Attempted to update project that is not loaded: /Users/jimmy/Desktop/cSharp/cSharp.csproj
Steps to reproduce
Whenever open C sharp project from icon or terminal
Expected behavior
Able to pick such debugger tools
Actual behavior
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 22
Sometimes the Visual Studio warning will still persist even after installing the .NET SDK. This is because a link/shortcut/alias needs to be created between the .NET executable install location and the Visual Studio path.
The executable was most likely installed in
/usr/local/share/dotnet/dotnet
. A symbolic link needs to be created tousr/local/bin
for Visual Studio.To create that link assuming the locations above use this in the Terminal:
$ ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/
For Ubuntu & Snap use this instead:
$ sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/
I have the 5.0.103 [/snap/dotnet-sdk/112/sdk] installed (as shown, using snap) on KDE neon (based on Ubuntu 20.04).
sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet
and restart Visual Studio Code. worked for me.I managed to resolve this by uninstalling dotnet via brew, breaking down and going to the website and just downloading and running that installer. Basically brew is somehow installing differently and its not properly tested by the omnisharp crew.
I saw something interesting in this issue: https://github.com/microsoft/vscode/issues/83155
Someone commented that launching VSCode from the terminal can solve the
PATH
issue. I tried in my machine (macOS 10.15.6):code .
(make sure that you’ve added VSCode to PATH before)Then I can run Omnisharp without issue.
To verify my guess, I’ve created added the following task in
task.json
:When I launched the app by clicking the app icon in your computer, and then run the task, I got this:
But I launched the app using
code .
, I got this:your path may not be the same as mine but the key is it does contains
/usr/local/share/dotnet
and that’s the key.I tried this and unfortuantly still have the same issue. I see the link in the usr/local/bin and if i click it is runs dotnet. But if i run vscode i still get the same issue. my only way to resolve this problem at the moment is to open vscode using terminal
you are god!
This doesn’t appear to be a duplicate of microsoft/vscode#107169 , simply setting the sdk path into the $PATH variable doesn’t fix it.