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 imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found.

See original GitHub issue

Issue Description

This problem occurs if I install dotnet from the Ubuntu 19.04 repositories. If I instead install from the Microsoft site, the problem does not occur. I don’t know if this is an OmniSharp issue, or an Ubuntu packaging issue. So I’ll start here, and if the issue belongs to Ubuntu, please let me know and Ill take it there.

Steps to Reproduce

Install dotnet-sdk-2.2 from the 19.04 repo. Then install Visual Studio Code from package code_1.36.1-1562627527_amd64.

IMPORTANT: After installing Visual Studio Code, start it up, and change the setting Omnisharp: Use Global Mono to “Never”.

Set up GtkSharp with "dotnet new -i “GtkSharp.Template.CSharp”

Then create a GtkSharp app with “dotnet new gtkapp”, and try to run it without debugging (or just build it from the terminal.)

Expected Behavior

App should build and run.

Actual Behavior

    Failed to load project file '/data/projects/dotnet/GtkApp/GtkApp.csproj'.

/data/projects/dotnet/GtkApp/GtkApp.csproj(1,1) Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project “/usr/lib/mono/xbuild/15.0/Microsoft.Common.props” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. /usr/share/dotnet/sdk/2.2.301/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props

Now, in Sdk.props, I see the following line for loading Microsoft.Common.props:

<Import Project=“$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props” />`

If I change this instead to:

<Import Project="/usr/share/dotnet/sdk/2.2.301/Current/Microsoft.Common.props" />

then everything builds and runs fine. So, something is not setting the MSBuild environment variables correctly. I’m not familiar wtih MSBuild, so I can’t figure out where those are constructed. Notice it is picking up the correct instance of Sdk.props from /usr/share/dotnet, but then attempting to load Microsoft.Common.props from /usr/lib/mono. But it shouldn’t be doing that, since I told Code to never use Global Mono.

Logs

OmniSharp log

    Failed to load project file '/data/projects/dotnet/GtkApp/GtkApp.csproj'.

/data/projects/dotnet/GtkApp/GtkApp.csproj(1,1) Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project “/usr/lib/mono/xbuild/15.0/Microsoft.Common.props” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. /usr/share/dotnet/sdk/2.2.301/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props

C# log

Post the output from Output-->C# here
Nothing

Environment information

VSCode version: 1.36.1 C# Extension: 1.20.0

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.2.301 Commit: 70d6be0814

Runtime Environment: OS Name: ubuntu OS Version: 19.04 OS Platform: Linux RID: ubuntu.19.04-x64 Base Path: /usr/share/dotnet/sdk/2.2.301/

Host (useful for support): Version: 2.2.6 Commit: 7dac9b1b51

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

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.6 [/usr/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
csharp ms-vscode 1.20.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:11
  • Comments:16

github_iconTop GitHub Comments

5reactions
jessfdm-codescommented, Nov 27, 2019

I get a very similar issue with the following error when trying to load a .net core project within a Unity C# solution on OSX: Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/Library/Frameworks/Mono.framework/Versions/5.16.0/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/[username]/.vscode/extensions/ms-vscode.csharp-1.21.8/.omnisharp/1.34.8/omnisharp/OmniSharp.exe.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths. /usr/local/share/dotnet/sdk/2.2.300/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props

I resolved it by installing the lastest version of Mono

1reaction
Vulfoxcommented, Jul 31, 2019

@ar-tour , it is written in the OP’s post under the “Actual Behavior” title. It mentions changing this file /usr/share/dotnet/sdk/2.2.301/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props by replacing the interpolated path to a hardcoded path.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to Build My Solution using command
Build.Exceptions.InvalidProjectFileException: The imported project “C:\Program Files (x86)\MSBuild\2.0\Microsoft.Common.props” was not found.
Read more >
MSBuild Error While creating new project in VS - MSDN
Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Read more >
When opening csproj in VSCode, OmniSharp throws error
Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found.
Read more >
The imported project was not found | solrevdev tech radar
Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found.
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