Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found.
See original GitHub issueIssue 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
Environment information
VSCode version: 1.36.1 C# Extension: 1.20.0
Mono Information
OmniSharp using built-in monoDotnet Information
.NET Core SDK (reflecting any global.json): Version: 2.2.301 Commit: 70d6be0814Runtime 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:
- Created 4 years ago
- Reactions:11
- Comments:16
Top GitHub Comments
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
@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.