Omnisharp-vscode: Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.

Created on 12 Jan 2019  路  13Comments  路  Source: OmniSharp/omnisharp-vscode

Looking through the other bugs on this topic I didn't see one that quite matched what I am seeing. It looks like Omnisharp finds a SDK it likes but then errors out anyway. This is Windows, no mono on the box, should be nothing out of the ordinary.

The only potentially interesting thing about this machine is that I installed the 4.6.1 targeting pack, but I don't see anything like that referenced in the log.

Log with COREHOST_TRACE below.

Environment data

dotnet --info output:
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview-010046
Commit: 77865edb2c

Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview-010046\

Host (useful for support):
Version: 3.0.0-preview-27308-3
Commit: 2f528e5f15

.NET Core SDKs installed:
2.1.503 [C:\Program Files\dotnet\sdk]
2.2.102 [C:\Program Files\dotnet\sdk]
3.0.100-preview-010046 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview-18630-0234 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview-27308-3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-alpha-27309-3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

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

VS Code version:
Version: 1.30.2 (user setup)
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:54:13.295Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Windows_NT x64 10.0.17763

C# Extension version:
1.17.1

Omnisharp log:
Starting OmniSharp server at 1/11/2019, 5:49:29 PM
Target: e:\source\hello

OmniSharp server started.
Path: C:\Users\billwert.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\OmniSharp.exe
PID: 268

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 15.0 - "C:\Users\billwert\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
    MSBUILD_EXE_PATH environment variable set to 'C:\Users\billwert\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\MSBuild.exe'
    Registered MSBuild instance: StandAlone 15.0 - "C:\Users\billwert\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
        CscToolExe = csc.exe
        CscToolPath = C:\Users\billwert\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin\Roslyn
        MSBuildExtensionsPath = C:\Users\billwert\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild
        MSBuildToolsPath = C:\Users\billwert\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin
    Detecting Cake files in 'e:\source\hello'.
    Could not find any Cake files
    Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
    No solution files found in 'e:\source\hello'
    Queue project update for 'e:\source\hello\hello.csproj'
    Detecting CSX files in 'e:\source\hello'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
    Configuration finished.
    Omnisharp server running using Stdio at location 'e:\source\hello' on host 6304.
    Loading project: e:\source\hello\hello.csproj
    Failed to load project file 'e:\source\hello\hello.csproj'.

e:\source\hello\hello.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. e:\source\hello\hello.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List1& projects, Boolean throwOnFileNotExistsError)
at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.Project.Initialize(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 globalProperties, String toolsVersion) at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath) at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath) at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader) at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func1 loader)

    Attemped to update project that is not loaded: e:\source\hello\hello.csproj

Steps to reproduce

dotnet new console
code .

Expected behavior

Omnisharp loads properly, intellisense works.

Actual behavior

Does not work.

.Net sdk not found

Most helpful comment

Hi all, I suspect that this is resolved by the 1.19.0 build we just released to the marketplace. Please give it a try!

All 13 comments

This only breaks when I install the newest CLI SDK from /dotnet/core-sdk. Using the released preview1 3.0 SDK from December (3.0.0-preview-27122-01) works fine.

    Attemped to update project that is not loaded:

I also encountered a similar error. asp.net core

Get the same if 3.0-preview installed.

I had the same issue, and make sure you run 'Visual Studio Installer' and check 'Visual Studio Build Tools' has been installed.

image

Was working perfectly on my Linux. Updated dotnet and code (no idea which broke it).

````
ambs ~ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.602
Commit: 04475eb7cf

Runtime Environment:
OS Name: linuxmint
OS Version: 19.1
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/2.1.602/

Host (useful for support):
Version: 2.1.9
Commit: dcedc87d22

.NET Core SDKs installed:
2.1.602 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

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

dotnet build works perfectly on the command line.

Thanks

I had the same issue, and make sure you run 'Visual Studio Installer' and check 'Visual Studio Build Tools' has been installed.

image

@rasikas Did this successfully fix the problem for you?

I also have this issue on my windows 10 insider's build version 18875.

My dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   2.2.203
 Commit:    e5bab63eca

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18875
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.203\

Host (useful for support):
  Version: 2.2.4
  Commit:  f95848e524

.NET Core SDKs installed:
  2.2.203 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

VS Code version: 1.33.1 (user setup)

Hi all, I suspect that this is resolved by the 1.19.0 build we just released to the marketplace. Please give it a try!

@DrakeLambert yeah for me that fixed the issue

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   2.2.103
 Commit:    8edbc2570a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.103\

Host (useful for support):
  Version: 2.2.1
  Commit:  878dd11e62

.NET Core SDKs installed:
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.2.103 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

Fixed here too!

The new omnisharp build fixed the issue for me. Thanks!

@Zalgo2462 Thank you VERY MUCH for the hint!

I had the same on nixos. Setting "UseLegacySdkResolver": true fixed it.

Was this page helpful?
0 / 5 - 0 ratings