Mono: [msbuild] Microsoft.CSharp.Core.targets was not found

Created on 7 Jun 2019  路  37Comments  路  Source: mono/mono

After bumping to the latest 2019-02 (hash c22486e39d129cb8117177a6f9c768e69fc4ebaa) in the master of macios we get the following error when trying to run our tests on classic:

07:30:04.7764270 /Users/builder/Library/Caches/VisualStudio/7.0/MSBuild/94375_1/Microsoft.CSharp.CurrentVersion.targets(331,5): error MSB4019: The imported project "/Users/builder/Library/Caches/VisualStudio/7.0/MSBuild/94375_1//Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Full failures can be found here: https://jenkins.mono-project.com/job/xamarin-macios-pr-builder/10198/Test_20Report/

This was done on PR: https://github.com/xamarin/xamarin-macios/pull/6221 which cannot be landed and is blocking the bump on master.

msbuild regression target-xamarin-ios

Most helpful comment

For anyone else having this issue under ArchLinux

Revert from mono-6.0.0.x to anything below.

All 37 comments

/cc @lewing

Which version of vsmac are you using here?

@mrward @rodrmoya Looks like the Current changes are required for vsmac here.
@mandel-macaque That upstream issue is not related to this.

We didn't backport the Current change to 8.0, which I guess is what @mandel-macaque is using?

From the cache location it looks like VS Mac 7.x is being used which, along with VS Mac 8.0, does not support MSBuild 16 (introduced in Mono 5.18.1.24 and later) which uses Current.

/Users/builder/Library/Caches/VisualStudio/7.0

as an FYI I am getting the same error:

/Users/nmartin/Library/Caches/VisualStudio/8.0/MSBuild/12219_1/Microsoft.CSharp.CurrentVersion.targets(5,5): Error MSB4019: The imported project "/Users/nmartin/Library/Caches/VisualStudio/8.0/MSBuild/12219_1//Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. (MSB4019) 

On VS 8. Full Info here:

=== Visual Studio Community 2019 for Mac ===

Version 8.0.9 (build 5)
Installation UUID: 51626b30-472b-43c3-be8e-84be0a9f345b
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.6.0.2 (d16-0 / 040682909)

Package version: 600000286

=== Mono Framework MDK ===

Runtime:
Mono 6.0.0.286 (2019-02/c22486e39d1) (64-bit)
Package version: 600000286

=== NuGet ===

Version: 4.8.2.5835

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.1.9
SDK: /usr/local/share/dotnet/sdk/2.1.505/Sdks
SDK Version: 2.1.505
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.9
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 10.2.1 (14490.122)
Build 10E1001

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 12.8.0.2 (Visual Studio Community)
Hash: f2248ae6
Branch: d16-0
Build date: 2019-04-23 11:59:04-0400

=== Xamarin Designer ===

Version: 4.17.4.420
Hash: 0a2420845
Branch: remotes/origin/d16-0
Build date: 2019-05-23 23:40:02 UTC

=== Xamarin.Android ===

Version: 9.2.3.0 (Visual Studio Community)
Android SDK: /Users/nmartin/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.0
SDK Build Tools Version: 27.0.3

Build Information:
Mono: mono/mono/2018-08-rc@5ac37ccd385
Java.Interop: xamarin/java.interop/d16-0@c987483
LibZipSharp: grendello/LibZipSharp/d16-1@44de300
LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
MXE: xamarin/mxe/xamarin@b9cbb535
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.26.0@325e91a
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-0@0a7edd6

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/nmartin/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 1.2.0.14
Hash: 86df26f
Branch: remotes/origin/d16-0
Build date: 2019-05-28 18:18:20 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 800090005
Git revision: 72a44477dd706608c2300a568f71e5769f89f7ef
Build date: 2019-05-29 15:19:54+00
Build branch: release-8.0
Xamarin extensions: 3e94aa3836143b8f5a5b9151b61a80e2fd278d62

=== Operating System ===

Mac OS X 10.14.5
Darwin 18.6.0 Darwin Kernel Version 18.6.0
Thu Apr 25 23:16:27 PDT 2019
root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

as a follow-up, is there ANY workaround? this has me 100% blocked

Use an older mono. If you have more than one version installed, then you can select a different (older) mono runtime in Preferences -> Projects -> .NET Runtimes .

This affects both iOS and macOS on master
https://github.com/xamarin/xamarin-macios/pull/6226

We have added the max version to be 176 and tests pass: https://github.com/xamarin/xamarin-macios/pull/6221

Use an older mono. If you have more than one version installed, then you can select a different (older) mono runtime in Preferences -> Projects -> .NET Runtimes .

According to later messages in this issue, reverting to 6.0.0.176 should fix this, but it doesn't for me. I have also reverted to 5.18.1 and the issue persists

Edit to add: the reference in the project file:

<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />

, but $(MSBuildExtensionsPath) resolves to:

"/Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Also, tried to find "Xamarin/iOS/Xamarin.iOS.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" and "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/docker/MonoDevelop.Docker/MSbuild" . These search paths are defined in "/Users/nmartin/Library/Caches/VisualStudio/8.0/MSBuild/20954_1/MonoDevelop.MSBuildBuilder.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.

If I search /Library for 'Xamarin.iOS.CSharp.targets', I find it here:
./Frameworks/Xamarin.iOS.framework/Versions/Current/lib/msbuild/iOS/Xamarin.iOS.CSharp.targets

@mandel-macaque Is there a requirement that you must use vsmac 7.x ? This issue is fixed with vsmac >8.0 .
The issue here is that newer msbuild dropped the ToolsVersion=15.0 and replaced it with ToolsVersion=Current. VSMac tries to use 15.0, and new msbuild can't find it, thus a roslyn property $(RoslynTargetsPath) is not set, causing msbuild to look for the Microsoft.CSharp.Core.targets in msbuild bin dir itself.

@nikmartin I think you are hitting a different issue now. Do you have /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets? And whats the exact mono version that you are using? mono -- version

@radical thanks! we're trying to bump to 8.0 on master and will backport to other branches if it solves the issue.

@mrward @rodrmoya Is the issue fixed in 8.0 or 8.1? Can you suggest version to use here (and on https://github.com/xamarin/xamarin-macios/pull/6238)?

Results from https://github.com/xamarin/xamarin-macios/pull/6238 seems to indicate that setting the minimum to VS4M 8.0 fix the issue. Thanks!

@mrward @rodrmoya Is the issue fixed in 8.0 or 8.1? Can you suggest version to use here (and on xamarin/xamarin-macios#6238)?

the Current bit, in 8.1 only.

I have got a similar thing with Xamarin Forms for Android while using a pipeline on Azure Devops.
It all works in my own environment.

I did fresh installation for Visual Studio MAC 2019(latest) on macOS Mojave and my older project which was successfully working on older Visual Studio is now breaking with build errors.

/Users/snehaljadhav/Documents/ACI_GPS/TFSMap/Silicus/ACI-GPS-Mobile/ACI_GPS/iOS/ACI_GPS.iOS.csproj(11,11): Error MSB4226: The imported project "/Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Also, tried to find "Xamarin/iOS/Xamarin.iOS.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" and "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/docker/MonoDevelop.Docker/MSbuild" . These search paths are defined in "/Users/snehaljadhav/Library/Caches/VisualStudio/8.0/MSBuild/8143_1/MonoDevelop.MSBuildBuilder.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. (MSB4226) (ACI_GPS.iOS)

Still an issue in latest VS default installation. Installing mono 5.20.1 doesnt fix it either.

Error MSB4226: The imported project "/Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Also, tried to find "Xamarin/iOS/Xamarin.iOS.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" and "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/docker/MonoDevelop.Docker/MSbuild" . These search paths are defined in "/Users/nathanvarghese/Library/Caches/VisualStudio/8.0/MSBuild/23072_1/MonoDevelop.MSBuildBuilder.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. (MSB4226)

After updating mono from preview channel:
"/Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/xbuild/Xamarin/iOS/Xamarin.MonoTouch.CSharp.targets" was not found. Also, tried to find "Xamarin/iOS/Xamarin.MonoTouch.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" and "/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/AddIns/docker/MonoDevelop.Docker/MSbuild" . These search paths are defined in "/Users/nathanvarghese/Library/Caches/VisualStudio/8.0/MSBuild/23558_1/MonoDevelop.MSBuildBuilder.exe.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. (MSB4226)

What is the correct path?

I have this problem on Ubuntu 18.04

Same on Mint 18.3

I have this problem on Ubuntu 16.04
Happened today after ubuntu updates which included Mono & Monodevelop updates.
Running
MonoDevelop 7.8.2 (build 2)
Momo 5.20.1.34 (tarball Tue July 16)

Copying the same project onto another PC with the only difference being an earlier version of Mono (5.20.1.19, April 11 2019), the project compiles OK with no errors.

I too am having this problem, on Ubuntu 18.04, with this error popping up in Monodevelop. I uninstalled everything mono that I could find and reinstalled mono-complete and monodevelop. Same problem. Removing the System.dll reference within Monodevelop and adding it back sometimes allows Monodevelop to do the build, but the fix isn't permanent.

Running the make outside of Monodevelop using our scripts works fine, however . . . there's a bunch that goes on, but at the core it's:

msbuild /verbosity:minimal /m

I'm running mono 5.20.1.34 and monodevelop 7.8.2 build 2, same as @darylgi.

The problem on Ubuntu 16.04 is now fixed.

Installing the latest ubuntu updates, there were further updates to mono & monodevelop.
I am now running mono 6.0.0.313 and monodevelop 7.8.4 (build 2) - it is fixed in these releases.

Same on Ubuntu 18.04, problem is fixed now -- thank goodness.

ok i have not been on Linux in a long time, got a raspberry pi to try and create something.
got the os installed and got the current installs of mono and mono develop and i am getting this error when i try and build a sample "hello, world"
from the Mono Develop web site it says that 7.6 is the current release and that is what is installed.
mono is 6.0.0.313

do i need to install a newer mono develop that is not released yet?
or do i need some package that adds ms build to the raspberry pi ?

Hello, I have the same problem with the RaspberryPi! After a test this morning the current release version (7.6.9.22 , www.monodevelop.com) is still affected by the bug.

Where can I download the version monodevelop 7.8.4 (build 2)?

Looks like the "Mono Develop" web site releases posted and the GitHub site a way different in release numbers.
look here: https://github.com/mono/monodevelop
and here: https://github.com/mono/monodevelop/releases

in github they are on 8.2.xxxx but the web site is only showing 7.6.xxx
so if the build problem is with Mono Develop then i think we need to address the issue there.

I was able to resolve the issue by selecting an older mono in the Visual Studio for Mac .net runtime preferences (Preferences > .net runtime).

Non working Mono 6.4.0.150. Selecting an older one installed, 5.18.1.3 in my case, resolved the issue.

Thanks for the tip.

For anyone else having this issue under ArchLinux

Revert from mono-6.0.0.x to anything below.

Solution for Raspbian on Raspberry Pi is here: https://github.com/mono/monodevelop/issues/8304#issuecomment-544977546

I had the same problem with Monodevelop under Raspian (Rasberry3)
I believe I can now offer a viable solution:
(for Monodevelop, Raspian, Raspberry 3)

It's just a setting that has to be done in Monodevelop before you start a new project:

Search under the settings, create and disable the line "create with MSBuild instead of xbuild".

After that all new projects will be recognized without errors.

For old projects the procedure is similar:
but there you should delete the folder ".vs" in the project folder first (better make a backup copy first! ;) )
Start Monodevelop. Check that the settings are as described above.
Then open the project in Monodelop.
When you open the project, it will be reinitialized and can then be edited and compiled without any problems.

a corrupted mono install on one machine led to mono package reinstall, which lead to this error. unfortunately ubuntu is now tracking 6.x and 4.x mono but not 5.x, so had to build a 5.18.0.240 mono to match last ubuntu 5.x.

That fixed this exact missing core.targets error on the command-line, but not in monodevelop. Also oddly for days couldn't open monodevelop projects that were targetting older mono versions- it would just crash and coredump. Somehow that cleared up on it's own, then got the core.targets error in MD. using parallel mono 5.x didn't fix the build issues, but upgrading monodevelop to 7.8 got everything building again on mono 6.8.

thanks for all detailed reporting it was very helpful in working through the issue

I have success after updated the vs for mac version 8.0.

I started getting a similar error after upgrading to Ubuntu 20.04. The solution that worked for me was to apt install mono-roslyn from mono-develop's 18.04 repos. https://askubuntu.com/a/1231973/1073658

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoseTiagoCarvalho picture JoseTiagoCarvalho  路  3Comments

imranazad picture imranazad  路  3Comments

kdubau picture kdubau  路  3Comments

triztian picture triztian  路  4Comments

decriptor picture decriptor  路  4Comments