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.

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

See original GitHub issue

Environment data

dotnet --info
.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

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

(No Visual Studio)

VS Code version: 1.18.0 C# Extension version: ms-vscode.csharp-1.13.0

Steps to reproduce

Start OmniSharp server (On VS Code startup or Restart OmniSharp)

Expected behavior

OmniSharp server starts and loads all project files.

Actual behavior

[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file 'd:\my-proj\app-server\src\DMProg.Core\DMProg.Core.csproj'.

See OmniSharp log:

Starting OmniSharp server at 11/9/2017, 12:52:40 PM
    Target: d:\my-proj\app-server

OmniSharp server started
    Path: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\OmniSharp.exe
    PID: 9296

[dbug]: OmniSharp.MSBuild.Discovery.Providers.VisualStudioInstanceProvider
        An exception was thrown while retrieving Visual Studio instances.
System.DllNotFoundException: Unable to load DLL 'Microsoft.VisualStudio.Setup.Configuration.Native.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at OmniSharp.MSBuild.Discovery.Interop.GetSetupConfiguration(ISetupConfiguration& configuration, IntPtr reserved)
   at OmniSharp.MSBuild.Discovery.Interop.GetSetupConfiguration()
   at OmniSharp.MSBuild.Discovery.Providers.VisualStudioInstanceProvider.GetInstances()
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin"
            CscToolExe = csc.exe
            CscToolPath = D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\Roslyn
            MSBuildExtensionsPath = D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild
            MSBuildToolsPath = D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Resolved 'Microsoft.Build.Framework' to 'D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\Microsoft.Build.Framework.dll'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Workspaces, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.CodeAnalysis.VisualBasic.Features, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'd:\my-proj\app-server'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in d:\my-proj\app-server
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Resolved 'Microsoft.Build' to 'D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\Microsoft.Build.dll'
[dbug]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuild environment: 
Mode: Standalone
RunningTests: False
RunningInVisualStudio: False
MSBuildToolsDirectory32: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin
MSBuildToolsDirectory64: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin
MSBuildSDKsPath: C:\Program Files\dotnet\sdk\1.0.1
CurrentMSBuildConfigurationFile: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\MSBuild.exe.config
CurrentMSBuildExePath: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\MSBuild.exe
CurrentMSBuildToolsDirectory: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin
VisualStudioInstallRootDirectory: 
MSBuildExtensionsPath: D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        No solution files found in 'd:\my-proj\app-server'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Resolved 'Microsoft.Build' to 'D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\Microsoft.Build.dll'
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: d:\my-proj\app-server\src\DMProg.Core\DMProg.Core.csproj
[dbug]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        'MSBuildExtensionsPath' set to 'D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild'
[dbug]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        'CscToolPath' set to 'D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\Roslyn'
[dbug]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
        'CscToolExe' set to 'csc.exe'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.resources, Version=15.1.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a'
[dbug]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Attempting to resolve 'Microsoft.Build.resources, Version=15.1.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a'
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file 'd:\my-proj\app-server\src\DMProg.Core\DMProg.Core.csproj'.
d:\my-proj\app-server\src\DMProg.Core\DMProg.Core.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  d:\my-proj\app-server\src\DMProg.Core\DMProg.Core.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.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(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.LoadProject(String filePath, String solutionDirectory, ILogger logger, MSBuildInstance msbuildInstance, MSBuildOptions options, ICollection`1 diagnostics, ImmutableArray`1& targetFrameworks)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Create(String filePath, String solutionDirectory, ILogger logger, MSBuildInstance msbuildInstance, MSBuildOptions options, ICollection`1 diagnostics)
   at OmniSharp.MSBuild.MSBuildProjectSystem.LoadProject(String projectFilePath)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:28 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
DustinCampbellcommented, Nov 9, 2017

@anorborg : As a workaround, you should also be able to make it work by setting the MSBuildSDKsPath environment variable to /usr/local/share/dotnet/sdk/2.0.2/Sdks.

3reactions
cjaeckelcommented, Nov 9, 2017

Sorry I need to update my issue report. The OmniSharp log above was produced with an environment set to an obvious wrong location. When setting

MSBuildSDKsPath=C:\Program Files\dotnet\sdk\1.0.1\Sdks

it is working.

BUT with out any MSBuildSDKsPath being set it defaults to the non existing path

D:\User\cja\.vscode\extensions\ms-vscode.csharp-1.13.0\.omnisharp\msbuild\15.0\Bin\Sdks

and the mentioned error occurs.

So, it seems to be required to explicitly set the environment MSBuildSDKsPath (correctly) in order to get OmniSharp to run with version 1.13.0

This was not necessary with previous versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The SDK 'Microsoft.NET.Sdk' specified could not be found ...
When I open my C# project with vs code, OminiSharp log print warn : Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.
Read more >
MSB4236: The SDK 'name' specified could not be found.
This error occurs when an MSBuild SDK couldn't be loaded. ... NET SDK (Microsoft.NET.Sdk.Web). MSBuild project SDKs can be delivered NuGet ...
Read more >
The SDK 'Microsoft.NET.Sdk' specified could not be found
Build.Tasks.Pack drwxr-xr-x 5 root root 4096 Απρ 5 19:48 Xamarin.IoT.Sdk. Go detected. Rider is not able find "Microsoft.NET.Sdk" when using a simple ...
Read more >
The SDK 'Microsoft.NET.Sdk.Web' specified could not be found
Opening solution with couple of exe -projects (netcoreapp1.1). None of exe projects will load, getting error "The SDK 'Microsoft.NET.Sdk.Web' specified could ...
Read more >
Missing SDK when using the Microsoft.Build package in .NET ...
Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found. at Microsoft.Build.Shared.
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