dotnet / vscode-csharp

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

.NET Core SDK not found on snap install #4201

Open Katekko opened 3 years ago

Katekko commented 3 years ago

Environment data

.NET Core SDK (reflecting any global.json):
 Version:   3.1.404
 Commit:    470f6754b3

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /snap/dotnet-sdk/104/sdk/3.1.404/

Host (useful for support):
  Version: 3.1.10
  Commit:  1721e39439

.NET Core SDKs installed:
  3.1.404 [/snap/dotnet-sdk/104/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.10 [/snap/dotnet-sdk/104/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.10 [/snap/dotnet-sdk/104/shared/Microsoft.NETCore.App]

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

VS Code version:

Version: 1.51.0
Commit: fcac248b077b55bae4ba5bab613fd6e9156c2f0c
Date: 2020-11-05T18:16:10.374Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.4.0-52-generic

C# Extension version: 1.23.5 (I already tried the 1.23.6-beta)

OmniSharp log

Starting OmniSharp server at 11/10/2020, 8:19:01 PM
    Target: /home/katekko/Projects/NextCode/XMS/api_xms

OmniSharp server started.
    Path: /home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/run
    PID: 23566

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on ubuntu 20.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 16.8.0 - "/home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to '/home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 16.8.0 - "/home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
            CscToolExe = csc.exe
            MSBuildToolsPath = /home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
            CscToolPath = /home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Roslyn
            BypassFrameworkInstallChecks = true
            MSBuildExtensionsPath = /home/katekko/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/home/katekko/Projects/NextCode/XMS/api_xms'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in '/home/katekko/Projects/NextCode/XMS/api_xms'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/home/katekko/Projects/NextCode/XMS/api_xms/api_xms.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/katekko/Projects/NextCode/XMS/api_xms'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[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.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/home/katekko/Projects/NextCode/XMS/api_xms' on host 23264.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /home/katekko/Projects/NextCode/XMS/api_xms/api_xms.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 '/home/katekko/Projects/NextCode/XMS/api_xms/api_xms.csproj'.
/home/katekko/Projects/NextCode/XMS/api_xms/api_xms.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.  /home/katekko/Projects/NextCode/XMS/api_xms/api_xms.csproj
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <25851c819cf84f6c96378e77482fea8f>: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) [0x00309] in <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate () [0x00139] in <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>: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 <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <25851c819cf84f6c96378e77482fea8f>:0 
  at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <25851c819cf84f6c96378e77482fea8f>:0 
  at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath, System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] projectConfigurationsInSolution) [0x00160] in <4b571290e6ee4e169cbb7c86cde8d5cd>:0 
  at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath, System.Collections.Generic.IReadOnlyDictionary`2[TKey,TValue] configurationsInSolution) [0x0000d] in <4b571290e6ee4e169cbb7c86cde8d5cd>: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 <4b571290e6ee4e169cbb7c86cde8d5cd>:0 
  at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass31_0.<LoadProject>b__0 () [0x00000] in <4b571290e6ee4e169cbb7c86cde8d5cd>: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 <4b571290e6ee4e169cbb7c86cde8d5cd>:0 

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: /home/katekko/Projects/NextCode/XMS/api_xms/api_xms.csproj

Steps to reproduce

Just tried to start my project that worked in the past

Expected behavior

All works, Intellisense and code review from c#.

Actual behavior

My Intellisense and code has stopped. When I type in the file I receive this message:

[info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
        Could not find document for file /home/katekko/Projects/NextCode/XMS/api_xms/Controllers/turma/TurmaController.cs

Screenshot from 2020-11-10 20-22-49

But when I try to run the project, runs perfectly (if I don't miss anything on my code)

333fred commented 3 years ago

Looking at that log, it appears you've installed .NET as a snap. I'm unsure whether omnisharp has support for picking up .NET from a snap install, @JoeRobich?

Katekko commented 3 years ago

Looking at that log, it appears you've installed .NET as a snap. I'm unsure whether omnisharp has support for picking up .NET from a snap install, @JoeRobich?

What is the right way to install the .NET in ubuntu?

JoeRobich commented 3 years ago

@Katekko These are the instructions for installing .NET SDK on Ubuntu - https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004-

Katekko commented 3 years ago

Strange, I already did that tutorial. And I follow one more time, and nothing.

Seems my dotnetcore is installed correctly, idk why my omnisharp stopped. I suspect the last version of vscode and omnisharp

JoeRobich commented 3 years ago

@Katekko Ok, well if installing with apt didn't get things working. 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.

michaelbarkdoll commented 3 years ago

I also experience this issue installing with snap on CentOS 8.

ArturSymanovic commented 3 years ago

Had same issue, spend very long time trying differnt things in the end fixed this with the following:

For a quick fix creating a symlink at /usr/local/bin/dotnet seems to solve the issue. sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet Originally posted by @nelsontkq in https://github.com/OmniSharp/omnisharp-vscode/issues/3077#issuecomment-498880626

wedreamer commented 3 years ago

Had same issue, spend very long time trying differnt things in the end fixed this with the following:

  • Reinstalled Ubuntu 20.04
  • Installed dotnet sdk (version 5.0.100) via snap:
  • Installed code via snap
  • Added the following symlink (big thanks to @nelsontkq)

For a quick fix creating a symlink at /usr/local/bin/dotnet seems to solve the issue. sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet Originally posted by @nelsontkq in #3077 (comment)

this answer helped me solve the problem,thanks your share