omnisharp-roslyn: Ubuntu: "The SDK 'Microsoft.Net.Sdk' specified could not be found."

From @https://github.com/Vannevelj I’ve installed the net core 2.1 SDK and the projects load correctly. I then installed the 3.0-preview and changed the solution to use this instead and now they can no longer load in VSCode. It loads perfectly fine on my Windows machine.

I’ve tried setting the SDK path environment variable explicitly but no difference: MsBuildSDKsPath=/usr/share/dotnet/sdk/3.0.100-preview-010184/Sdks/ as well as changing omnisharp.path to latest, setting the path inside omnisharp.json directly and using the insiders build of VSCode.

Is there anything off in my environment? I’ve created a VM with Linux specifically to test .net core 3 on it so there shouldn’t be anything unusual interfering with things. Happy to try out whatever you can suggest.

Example csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>8.0</LangVersion>
    <IsPackable>false</IsPackable>
  </PropertyGroup>
  <ItemGroup>
      <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
      <PackageReference Include="Mongo2Go" Version="2.2.8" />
      <PackageReference Include="Moq" Version="4.7.145" />
      <PackageReference Include="xunit" Version="2.2.0" />
      <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\src\MyApp.Client\MyApp.Client.csproj" />
    <ProjectReference Include="..\..\..\src\MyApps\MyApp.csproj" />
  </ItemGroup>
</Project>

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview-010184
 Commit:    c57bde4593

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/3.0.100-preview-010184/

Host (useful for support):
  Version: 3.0.0-preview-27324-5
  Commit:  63a01b08e5

.NET Core SDKs installed:
  2.2.103 [/usr/share/dotnet/sdk]
  3.0.100-preview-010184 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview-19075-0444 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview-27324-5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

VS Code version:

Version: 1.30.2
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:49:48.319Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Linux x64 4.15.0-32-generic

C# Extension version: 1.17.1

Steps to reproduce

  1. Install 2.2.1 SDK
  2. Install 3.0-preview SDK
  3. dotnet new console
  4. Open via code .

Expected behavior

The project loads correctly and code lens options show.

Actual behavior

Errors in the output and no code lens available. However, using dotnet run runs the project as intended.

Starting OmniSharp server at 27/01/2019, 20:04:35
Target: /home/jeroen/Documents/github/my-app/MyApp.Webapp.sln

OmniSharp server started.
Path: /home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/run
PID: 20475

[info]: OmniSharp.Stdio.Host
Starting OmniSharp on ubuntu 18.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "/home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 15.0 - "/home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin"
MSBuildExtensionsPath = /home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild
BypassFrameworkInstallChecks = true
CscToolPath = /home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin/Roslyn
CscToolExe = csc.exe
MSBuildToolsPath = /home/jeroen/.vscode/extensions/ms-vscode.csharp-1.17.1/.omnisharp/1.32.8/omnisharp/msbuild/15.0/Bin
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/jeroen/Documents/github/my-app'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/home/jeroen/Documents/github/my-app/MyApp.Webapp.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/jeroen/Documents/github/my-app/src/MyApp.Webapp/MyApp.Webapp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/jeroen/Documents/github/my-app/src/MyApp.Client/MyApp.Client.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/jeroen/Documents/github/my-app/src/MyApp/MyApp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/jeroen/Documents/github/my-app/tests/unit/MyApp.Tests/MyApp.Tests.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/jeroen/Documents/github/my-app'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/jeroen/Documents/github/my-app' on host 20382.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/jeroen/Documents/github/my-app/src/MyApp.Webapp/MyApp.Webapp.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/home/jeroen/Documents/github/my-app/src/MyApp.Webapp/MyApp.Webapp.csproj'.
/home/jeroen/Documents/github/my-app/src/MyApp.Webapp/MyApp.Webapp.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. /home/jeroen/Documents/github/my-app/src/MyApp.Webapp/MyApp.Webapp.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>: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, System.Boolean throwOnFileNotExistsError) [0x00254] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00024] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x00103] in <2338fdb301034c1d9c6b95e564d514b0>: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.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0001a] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0004c] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00034] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00023] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.Project.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) [0x00126] in <2338fdb301034c1d9c6b95e564d514b0>: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) [0x0009e] in <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>: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 <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f5] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <2338fdb301034c1d9c6b95e564d514b0>:0 
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <410de907c9654d6593c7a8d4ded6b20a>:0 
at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <410de907c9654d6593c7a8d4ded6b20a>:0 
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <410de907c9654d6593c7a8d4ded6b20a>:0 
at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass25_0.<LoadProject>b__0 () [0x00000] in <410de907c9654d6593c7a8d4ded6b20a>: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 <410de907c9654d6593c7a8d4ded6b20a>:0 

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 25 (5 by maintainers)

Most upvoted comments

I had a similar issue with DotnetCore 2.2. I added the following to .bashrc on Ubuntu:

export MSBuildSDKsPath=“/usr/share/dotnet/sdk/$(dotnet --version)/Sdks”

For ubuntu please try adding a omnisharp.json file as suggested here

@KeyurRamoliya you’re absolutely right, this problem has nothing to do with OS. On Windows it’s easier, because you have more options: you could install Visual Studio 2019, and than OmniSharp will be able to pick up MSbuild from it, thanks to VisualStudioInstanceProvider. On Linux and macOS you don’t have it. Even though there is VS for Mac, but the latest version of VS for Mac is 7.7, and it only supports .net core 2.2. The only way that I can see is to write a new implementation of MSBuildInstanceProvider, that will be able to pick up MSBuild from the path where .net core’s installed.

FYI if it helps anyone. I’ve got a Hyper-V VM running Ubuntu 19.04 and the snap vscode is installed, and I had this same issue, which I seem to have resolved by installing the dotnet-sdk snap and doing a “sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet” to manually create a symbolic link where Omnisharp would find it. In a perfect world, all I’d have to do is something like “sudo snap alias dotnet-sdk.dotnet dotnet” but I never could get Omnisharp to work that way as it appears to ignore /snap/bin or something (not sure). You can also just create a “~/bin” folder and make the symbolic link there (no sudo required, obviously, but I went ahead and made it system-wide for the VM).

Thanks! That got me to the next error: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found

But luckily that one has its own issue (OmniSharp/omnisharp-vscode#3049) 😄

I’m on Ubuntu 19.04 with both vscode and dotnet installed from snap. I haven’t manged to get it working by setting $MSBuildSDKsPath. (Or any other way, for that matter 🤓 )

On my Ubuntu 19.04 machine, I have 2.2.204 working (disclaimer: have not tried 3.0-preview), by making sure my snaps were all up to date with “sudo snap refresh” and then making sure I had a link to dotnet by doing something like (from memory, as I’m not on that machine at the moment): “sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet” to make a global link to “dotnet”. Making a snap alias was insufficient for VSCode, though for CLI work it was fine, so I removed it and did the symbolic link approach. This might all go out the window with the 3.0-preview, though. They had a problem with the SDK resolver in VSCode in the C# Omnisharp extension which is now fixed, I believe. I haven’t tried it in the last few days, though.

FWIW, on my Fedora installation where I suffered from this issues for months, I found out that the issue was that some dotnet symlink was dead in my installation. IIRC, it was the one in /opt/dotnet/dotnet that was broken, while .NET Core was installed someplace, and MSBuild was using this broken symlink anyway then failed resolution of Sdks. Removing the broken symlink fixed it.

@mickaelistria I appreciate your comment. Unfortunately, this was not my issue. In another Ubuntu VM, I am running Ubuntu 18.10 so I am using the Dotnet and VSCode snaps. I haven’t tried the suggestion above for it, yet. When I do, I will put in my .bash_aliases file instead of ,bashrc and use the path for the Snap Dotnet, which is something like /snap/dotnet-sdk/current… whatever, and I hope it will work. Before Dotnet 2.2.205, all I needed was a symlink to the snap version of dotnet, which I created as “/usr/local/bin/dotnet” pointing to the snap version of dotnet, and it worked fine. Not sure why that stopped working with this release, but I’ll try a modified version of the suggestion above and see. Fingers crossed. Hope you don’t have issues (I don’t on Windows, but I haven’t used Fedora in quite a while).

I’m on Ubuntu 19.04 with both vscode and dotnet installed from snap. I haven’t manged to get it working by setting $MSBuildSDKsPath. (Or any other way, for that matter 🤓 )

For folks hitting this issue on windows, please try installing .Net Core Build Tools as described here