Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ominisharp report error when VSCode loading my dotnet core project #1313

Closed
lixiaoqiang opened this issue Oct 10, 2018 · 10 comments

Comments

Projects
None yet
5 participants
@lixiaoqiang
Copy link

commented Oct 10, 2018

I encounter a problem when omnisharp loading my dotnet core project using vscode.

Omnisharp logs:

Starting OmniSharp server at 10/9/2018, 10:19:58 PM
    Target: d:\work\tools\XxxTransfer

OmniSharp server started.
    Path: C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\OmniSharp.exe
    PID: 22356

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 15.0 - "C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 15.0 - "C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin"
            CscToolExe = csc.exe
            CscToolPath = C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin\Roslyn
            MSBuildExtensionsPath = C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild
            MSBuildToolsPath = C:\Users\xiaoqiang\.vscode\extensions\ms-vscode.csharp-1.16.2\.omnisharp\1.32.5\msbuild\15.0\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'd:\work\tools\XxxTransfer'.
[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
        No solution files found in 'd:\work\tools\XxxTransfer'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'd:\work\tools\XxxTransfer\XxxTransfer.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'd:\work\tools\XxxTransfer'.
[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 'd:\work\tools\XxxTransfer' on host 21736.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: d:\work\tools\XxxTransfer\XxxTransfer.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'd:\work\tools\XxxTransfer\XxxTransfer.csproj'.
d:\work\tools\XxxTransfer\XxxTransfer.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.  d:\work\tools\XxxTransfer\XxxTransfer.csproj
   在 Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   在 Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, Boolean throwOnFileNotExistsError)
   在 Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement)
   在 Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   在 Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   在 Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
   在 Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   在 Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   在 Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   在 Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   在 Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   在 OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath)
   在 OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath)
   在 OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectLoader loader)
   在 OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader)

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: d:\work\tools\XxxTransfer\XxxTransfer.csproj

And below is my csproj file

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <LangVersion>latest</LangVersion>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <NoWarn>CS1591</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.3"/>
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2"/>
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1"/>
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1"/>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.3"/>
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1"/>
  </ItemGroup>
  <ItemGroup>
  </ItemGroup>
</Project>
@DustinCampbell

This comment has been minimized.

Copy link
Contributor

commented Oct 10, 2018

Could you share the output of dotnet --info?

@lixiaoqiang

This comment has been minimized.

Copy link
Author

commented Oct 11, 2018

@DustinCampbell

C:\Users\xxx>dotnet --info
.NET Core SDK(反映任何 global.json):
 Version:   2.1.403
 Commit:    04e15494b6

运行时环境:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.403\

Host (useful for support):
  Version: 2.1.5
  Commit:  290303f510

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

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

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

运行时环境 means "Runtime Environment"

@DustinCampbell

This comment has been minimized.

Copy link
Contributor

commented Oct 11, 2018

Thanks! I've seen some cases of SDK resolution failing to locate .NET Core SDK version 2.1.403, but haven't ever been able to reproduce it.

Try this to workaround the issue thy this:

  1. Add a file called omnisharp.json to your project folder with following content:
{
    "MsBuild": {
        "UseLegacySdkResolver": true
    }
}
  1. Restart OmniSharp.

Let me know if that addresses the problem for you.

@lixiaoqiang

This comment has been minimized.

Copy link
Author

commented Oct 12, 2018

@DustinCampbell
It did work, Thank you !!!! Thank you 10000000 times!!!

@TAGC

This comment has been minimized.

Copy link

commented Nov 16, 2018

This didn't work for me. After adding the omnisharp.json I still get this trace:

Starting OmniSharp server at 11/16/2018, 11:18:12 AM
    Target: c:\Users\<me>\Documents\VSCode\experiment

OmniSharp server started.
    Path: C:\Users\<me>\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\OmniSharp.exe
    PID: 15904

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 3 MSBuild instance(s)
            1: Visual Studio Build Tools 2017 15.8.28010.2048 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
            2: Visual Studio Community 2017 15.8.28010.2048 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin"
            3: StandAlone 15.0 - "C:\Users\<me>\.vscode\extensions\ms-vscode.csharp-1.17.1\.omnisharp\1.32.8\msbuild\15.0\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Build Tools 2017 15.8.28010.2048 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Users\<me>\Documents\VSCode\experiment'.
[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
        No solution files found in 'c:\Users\<me>\Documents\VSCode\experiment'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Users\<me>\Documents\VSCode\experiment\experiment.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Users\<me>\Documents\VSCode\experiment'.
[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 'c:\Users\<me>\Documents\VSCode\experiment' on host 10556.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Users\<me>\Documents\VSCode\experiment\experiment.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'c:\Users\<me>\Documents\VSCode\experiment\experiment.csproj'.
c:\Users\<me>\Documents\VSCode\experiment\experiment.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: Could not load SDK Resolver. A manifest file exists, but the path to the SDK Resolver DLL file could not be found. Manifest file path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\SdkResolvers\Microsoft.Build.NuGetSdkResolver\Microsoft.Build.NuGetSdkResolver.xml'. SDK resolver path: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll  c:\Users\<me>\Documents\VSCode\experiment\experiment.csproj
   at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.TryAddAssemblyFromManifest(String pathToManifest, String manifestFolder, List`1 assembliesList, ElementLocation location)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.FindPotentialSdkResolvers(String rootFolder, ElementLocation location)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers(LoggingContext loggingContext, ElementLocation location)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.Initialize(LoggingContext loggingContext, ElementLocation location)
   at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath)
   at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.<>c__DisplayClass3_0.<ResolveSdk>b__0(String key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
   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, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 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, Func`1 loader)

[fail]: OmniSharp.MSBuild.ProjectManager
        Attemped to update project that is not loaded: c:\Users\<me>\Documents\VSCode\experiment\experiment.csproj

Environment

$ dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   2.1.403
 Commit:    04e15494b6

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

Host (useful for support):
  Version: 2.1.5
  Commit:  290303f510

.NET Core SDKs installed:
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.302 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.401 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.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.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

This comment has been minimized.

Copy link
Contributor

commented Nov 29, 2018

@TAGC sorry for the delay. Could you file a separate issue? What you described is different and possibly solved by #1347 if you're launching VS Code from a Visual Studio console.

@TAGC

This comment has been minimized.

Copy link

commented Nov 29, 2018

Installing .NET Core build tools like @rainersigwald suggested in #1311 solved it for me.

@DustinCampbell

This comment has been minimized.

Copy link
Contributor

commented Nov 29, 2018

Great -- this has turned out to be an VS installer issue where one file is dropped on disk, but not another. I believe there are some plans to address this.

@kevnord

This comment has been minimized.

Copy link

commented Apr 13, 2019

@DustinCampbell Thank you for the tip! I've been battling vscode/omnisharp for a couple of days and it now works!

@radutomy

This comment has been minimized.

Copy link

commented Apr 16, 2019

@DustinCampbell your solution worked for me as well.
I've just installed Ubuntu from scratch, installed both dotnet and vscode from the snap store, and Omnisharp started complaining...

Creating a simlink (as per below) didn't work for me, however, your solution saved my bacon

"sudo ln -sv /usr/local/bin/dotnet /snap/dotnet-sdk/current/dotnet"

Btw, I've never had this problem when installing vscode and dotnet via sudo apt, so this leads me to believe that dotnet snap is broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.