Omnisharp-vscode: Failed to load project file(Microsoft.Build.Exceptions.InvalidProjectFileException)

Created on 19 Nov 2019  ·  2Comments  ·  Source: OmniSharp/omnisharp-vscode

Issue Description

I encounter a problem when omnisharp loading my dotnet core project using vscode. I have tried the export MSBuildSDKsPath=/usr/local/share/dotnet/sdk/$(dotnet --version)/Sdks,but it doesn't work.

It seems that dotnet build/run can work, but I can't use vscode to run/debug my dotnet project now.

Steps to Reproduce

  • run dotnet new console -o dotnet-learning
  • open the folder of dotnet-learning by vscode

Logs

OmniSharp log


Starting OmniSharp server at 11/19/2019, 9:10:39 PM
Target: /Users/qule/Development/dotnet-dev/dotnet-learning

OmniSharp server started.
Path: /Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/run
PID: 3475

    Starting OmniSharp on MacOS 10.15.1 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 16.3 - "/Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/omnisharp/.msbuild/Current/Bin"
    MSBUILD_EXE_PATH environment variable set to '/Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
    Registered MSBuild instance: StandAlone 16.3 - "/Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        TargetFrameworkRootPath = /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/xbuild-frameworks
        MSBuildToolsPath = /Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/omnisharp/.msbuild/Current/Bin
        CscToolPath = /Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/xbuild
    Detecting Cake files in '/Users/qule/Development/dotnet-dev/dotnet-learning'.
    Could not find any Cake files
    No solution files found in '/Users/qule/Development/dotnet-dev/dotnet-learning'
    Queue project update for '/Users/qule/Development/dotnet-dev/dotnet-learning/dotnet-learning.csproj'
    Detecting CSX files in '/Users/qule/Development/dotnet-dev/dotnet-learning'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Loading project: /Users/qule/Development/dotnet-dev/dotnet-learning/dotnet-learning.csproj
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
    Configuration finished.
    Omnisharp server running using Stdio at location '/Users/qule/Development/dotnet-dev/dotnet-learning' on host 3414.
    Failed to load project file '/Users/qule/Development/dotnet-dev/dotnet-learning/dotnet-learning.csproj'.

/Users/qule/Development/dotnet-dev/dotnet-learning/dotnet-learning.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/xbuild/Current/Microsoft.Common.props" was not found. Also, tried to find "Current/Microsoft.Common.props" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" . These search paths are defined in "/Users/qule/.vscode/extensions/ms-vscode.csharp-1.21.7/.omnisharp/1.34.7/omnisharp/OmniSharp.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. /usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00000] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ThrowForImportedProjectWithSearchPathsNotFound (Microsoft.Build.Evaluation.ProjectImportPathMatch searchPathMatch, Microsoft.Build.Construction.ProjectImportElement importElement) [0x000a2] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x001c2] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x00209] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00040] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x0011c] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Evaluator4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCacheBase projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext, System.Boolean interactive) [0x0002f] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0005e] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00035] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project.Initialize (System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00126] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00093] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <10b73e4bf233421cae439ef765e97ef0>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <10b73e4bf233421cae439ef765e97ef0>:0 at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <10b73e4bf233421cae439ef765e97ef0>:0 at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <8e0c87330ae04ce289446ebcdc79029c>:0 at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <8e0c87330ae04ce289446ebcdc79029c>:0 at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectIdInfo projectIdInfo, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <8e0c87330ae04ce289446ebcdc79029c>:0 at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass29_0.<LoadProject>b__0 () [0x00000] in <8e0c87330ae04ce289446ebcdc79029c>:0 at (wrapper delegate-invoke) System.Func1[System.ValueTuple3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult()
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loader) [0x0001b] in <8e0c87330ae04ce289446ebcdc79029c>:0

    Attempted to update project that is not loaded: /Users/qule/Development/dotnet-dev/dotnet-learning/dotnet-learning.csproj

C# log

Nothing

Environment information

VSCode version: 1.40.1
C# Extension: 1.21.7

Mono Information
OmniSharp using built-in mono

Dotnet Information
.NET Core SDK (reflecting any global.json):
Version: 3.0.100
Commit: 04339c3a26

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.0.100/

Host (useful for support):
Version: 3.0.0
Commit: 7d57652f33

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

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

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


Visual Studio Code Extensions

|Extension|Author|Version|
|---|---|---|
|code-settings-sync|Shan|3.4.3|
|cpptools|ms-vscode|0.26.1|
|csharp|ms-vscode|1.21.7|
|gc-excelviewer|GrapeCity|2.1.32|
|Go|ms-vscode|0.11.9|
|java|redhat|0.53.1|
|mssql|ms-mssql|1.7.1|
|python|ms-python|2019.11.49689|
|shell-format|foxundermoon|6.1.3|
|vscode-docker|ms-azuretools|0.8.2|
|vscode-hexdump|slevesque|1.7.2|
|vscode-html-format|mohd-akram|0.0.3|
|vscode-java-debug|vscjava|0.23.0|
|vscode-java-dependency|vscjava|0.6.0|
|vscode-java-pack|vscjava|0.8.0|
|vscode-java-test|vscjava|0.21.0|
|vscode-maven|vscjava|0.19.1|
|vscode-perl|cfgweb|1.18.0|
|vscode-xml|redhat|0.9.1|
|vscodeintellicode|VisualStudioExptTeam|1.2.0|;

Most helpful comment

please upgrade to Mono 6.4.0 or uninstall your Mono 5.4.1

All 2 comments

please upgrade to Mono 6.4.0 or uninstall your Mono 5.4.1

Thanks, I removed mono and it works!


refrence

Was this page helpful?
0 / 5 - 0 ratings