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

Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/usr/lib/mono/xbuild/15.0/Microsoft.Common.props" was not found. #3180

Open
guy-rouillier opened this issue Jul 17, 2019 · 16 comments

Comments

@guy-rouillier
Copy link

guy-rouillier commented Jul 17, 2019

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 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 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
@Vulfox
Copy link

Vulfox commented Jul 17, 2019

I am also experiencing the same issues. After I use this hotfix solution for the Sdk.props file, it fixes OmniSharp for my VSCode.

I have the same environment setup as the OP.

@akordzik
Copy link

@Vulfox
I am having the same issue. What hotfix solution you are talking about?

@Vulfox
Copy link

Vulfox commented 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.

@billksun
Copy link

billksun commented Aug 2, 2019

I am having the same issue but on NixOS, where I cannot edit Sdk.props as it is installed on a read-only file system.

@erikbackman
Copy link

I'm having the same problem with .net core projects on NixOS.

I'm using nix-shell --pure and then running code .

shell.nix

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "my-environment";

  buildInputs = [
    pkgs.dotnet-sdk
    pkgs.vscode
    pkgs.mono
    pkgs.dotnetPackages.Nuget
  ];
}

@T89L
Copy link

T89L commented Sep 12, 2019

I installed the latest mono (6.0.0) and told vscode to use the global mono and this was resolved

@jfcarr
Copy link

jfcarr commented Sep 30, 2019

Editing the Sdk.props file for 2.2 worked for me, but the problem returned when I switched to 3.0, and editing the Sdk.props file no longer resolves it.

OS: Ubuntu Mate 19.04 (Disco Dingo)
Kernel: 5.0.0-29
.NET Core: 3.0.100

@guy-rouillier
Copy link
Author

@jfcarr I just started up my Ubuntu Mate 19.04 VM, and installed .Net Core 3.0 SDK using the Package Manager instructions from here: https://dotnet.microsoft.com/download/dotnet-core/3.0

The workaround mentioned here is no longer needed. With 3.0, the app built and ran for me without having to modify any of the props files. The SDK installed to /usr/share/dotnet/sdk/3.0.100/.

@jfcarr
Copy link

jfcarr commented Sep 30, 2019

@guy-rouillier I installed it the same way, but the error occurs for me. Perhaps a carry-over of the 2.2 issue, since I had it installed previously.

@guy-rouillier
Copy link
Author

I also had 2.2 installed, and still do as a matter of fact. Have you changed the TargetFramework to netcoreapp3.0?

<TargetFramework>netcoreapp3.0</TargetFramework>

If so, the 2.2 props settings should not come into play.

@jfcarr
Copy link

jfcarr commented Oct 2, 2019

I got it working. In addition to editing Sdk.props, I also had to set this environment variable:

export MSBuildSDKsPath=/usr/share/dotnet/sdk/3.0.100/Sdks

@filmor
Copy link

filmor commented Nov 5, 2019

Things start working as soon as I move /usr/lib/mono/xbuild away from there, so apparently something within OmniSharp's msbuild still looks in the global paths, even if the bundled version is being used.

@felixfbecker
Copy link

felixfbecker commented Nov 21, 2019

I have the same issue (macOS). If anyone needs a repro, it happens on https://github.com/felixfbecker/PowerGit. I don't have mono installed at all, only .NET Core (several versions including v3).

@jessfdm-codes
Copy link

jessfdm-codes commented 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

@berryart
Copy link

berryart commented Dec 7, 2019

Installing Mono on MacOS helped me as well.

@jr549
Copy link

jr549 commented Mar 30, 2020

My fix for error in adrianwilczynski.add-reference:

Re: [GitHub Developer Support] - Microsoft.Common.Props not found -FIX

....vscode\extensions\ms-dotnettools.csharp-1.21.15.omnisharp\1.34.14.msbuild\Current\Microsoft.Common.Props

copy to

...\ProgramFiles\MSBuild\Current

JR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests