vscode-csharp: "'Microsoft.NET.Sdk' could not be found" when running VS Code from Git Bash
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.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 2
- Comments: 16 (4 by maintainers)
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.