question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

16reactions
metaleapcommented, Sep 9, 2019

My vote would be to reopen this issue, why?

This initial UX for Linux-based devs trying out .NET dev in VSCode via OmniSharp is sub-par, here’s how it goes if .NET Core isn’t in your distro’s package manager:

  • one downloads the .NET SDK, extracts it somewhere
  • sets env-var DOTNET_ROOT and ensures dotnet CLI is in PATH
  • all works, one can dotnet build and dotnet run and dotnet new projects just fine
  • try out the VScode C# extension aka OmniSharp!
  • “The SDK ‘Microsoft.Net.Sdk’ specified could not be found.”

Well? Your Nodejs extension likely executes msbuild or other processes via standard Nodejs process / command-exec APIs. You can set your own process’ env vars and they should be inherited by processes you spawn. You can also expressly elaborate the env for the process being spawned.

So what you do is: notice that MSBuildSDKsPath isn’t set but DOTNET_ROOT is set, then set the former on-the-fly to what @arcooke outlined, but basing on DOTNET_ROOT instead of /snap/.... of course, ie. $DOTNET_ROOT/sdk/$(dotnet --version)/Sdks.

Update: also, still with both env vars now set correctly and after rebooting, The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path pops in my face. I don’t care for debugging right now but with these 2 env vars set you totally should be able to “locate the .NET Core SDK”.

8reactions
ghostcommented, Mar 1, 2019

@akshita31

I can confirm that works. I added export MSBuildSDKsPath=/snap/dotnet-sdk/current/sdk/$(dotnet --version)/Sdks to bashrc and deleted the legacysdkresolver file and it builds successfully.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The SDK 'Microsoft.NET.Sdk.Web' specified could not be ...
Try the workaround solution bellow: Add a file called omnisharp.json to your project folder with following content
Read more >
The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
1 Answer · 1.Clean-up obsolete .NET Core versions: Go to Control Panel and uninstall previous . · 2.Create a Global.json file: Add a...
Read more >
The SDK 'Microsoft.NET.Sdk' specified could not be found
The SDK 'Microsoft.NET.Sdk' specified could not be found ; Type, Bug ; User priority, Prevents from using Rider P ; Technology, C# C...
Read more >
MSB4236 The SDK Microsoft.NET.Sdk specified could not be ...
After some googling the answer was to upgrade the Microsoft Visual Studio 2019 Build Tools installed on that server. 2020-01-11-14.57.39.png.
Read more >
error MSB4236: The SDK 'Microsoft.NET.SDK ...
NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found error. However since the solution contains classic projects mono is used for restoring and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found