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.NET.Sdk' could not be found" when running VS Code from Git Bash

See original GitHub issue

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Users\nosikil\scoop\apps\dotnet-sdk\current\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.15.0 C# Extension version: 1.12.1

Steps to reproduce

In Git Bash:

dotnet new console
code.cmd .

Note that Git, the .NET SDK and VS Code are installed with Scoop on my machine.

Expected behavior

This is what I get when running VS Code from the console or PowerShell:

Starting OmniSharp server at 14.9.2017, 15:09:52
    Target: d:\temp

OmniSharp server started
    Path: C:\Users\nosikil\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\OmniSharp.exe
    PID: 5580

OmniSharp: -s d:\temp --hostPID 4480 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
[info]: OmniSharp.Startup
        Omnisharp server running using Stdio at location 'd:\temp' on host 4480.
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in d:\temp
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Omnisharp will use local MSBuild.
    MSBUILD_EXE_PATH: C:\Users\nosikil\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild\MSBuild.exe
    MSBuildExtensionsPath: C:\Users\nosikil\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        No solution files found in 'd:\temp'
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: d:\temp\temp.csproj

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Update project: temp
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\temp'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Services.WorkspaceHelper
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Startup
        Configuration finished.

Actual behavior

This is what I get with Git Bash:

Starting OmniSharp server at 14.9.2017, 15:06:24
    Target: d:\temp

OmniSharp server started
    Path: C:\Users\nosikil\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\OmniSharp.exe
    PID: 12952

OmniSharp: -s d:\temp --hostPID 7308 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
[info]: OmniSharp.Startup
        Omnisharp server running using Stdio at location 'd:\temp' on host 7308.
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in d:\temp
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Omnisharp will use local MSBuild.
    MSBUILD_EXE_PATH: C:\Users\nosikil\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild\MSBuild.exe
    MSBuildExtensionsPath: C:\Users\nosikil\.vscode\extensions\ms-vscode.csharp-1.12.1\.omnisharp\msbuild

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        No solution files found in 'd:\temp'
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: d:\temp\temp.csproj
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file 'd:\temp\temp.csproj'.
d:\temp\temp.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  d:\temp\temp.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, String sdksPath, ILogger logger, MSBuildOptions options, ICollection`1 diagnostics, ImmutableArray`1& targetFrameworks)
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Create(String filePath, String solutionDirectory, String sdksPath, ILogger logger, MSBuildOptions options, ICollection`1 diagnostics)
   at OmniSharp.MSBuild.MSBuildProjectSystem.LoadProject(String projectFilePath)

[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\temp'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Services.WorkspaceHelper
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Startup
        Configuration finished.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
bandreicommented, Jul 10, 2018

I have the same issue on my macOS and I have no idea how to track the bug in omnisharp. I guess I’ll have to dig into the codebase to see where it’s taking its path from because it’s clearly not using the one where donet actually lives.

0reactions
cartermpcommented, Mar 26, 2020

Closing as a duplicate of #3541 which will track these issues

Read more comments on GitHub >

github_iconTop Results From Across the Web

Net SDK is not found in VSCode - Stack Overflow
When running "dotnet build -v diag" in bash I found that there is an Environment Variable "MSBuildSDKsPath" that was set to a non...
Read more >
dotnet run command - .NET CLI | Microsoft Learn
The dotnet run command provides a convenient option to run your application from the source code with one command.
Read more >
Visual Studio Code - ArchWiki
Code is a cross-platform text editor developed by Microsoft, built on the Electron framework. Visual Studio Code is a binary distribution of ...
Read more >
Setting up Visual Studio Code
Getting up and running with Visual Studio Code is quick and easy. It is a small download so you can install in a...
Read more >
How YOU can get started with .NET Core and C# in VS Code
Add a test project and run our tests; Add a Console program and use our library; Improve our IDE with vscode-solution-explorer extension. what...
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