Warm tip: This article is reproduced from stackoverflow.com, please click
azure azure-devops xamarin xamarin.ios

MTOUCH : error MT2002: Failed to resolve "System.Drawing.Color" reference

发布于 2020-04-08 09:26:31

I have a build issue with a Xamarin.iOS app in Azure DevOps that I haven't been able to solve. I'm wondering if anyone has any suggestions.

Building the iOS version of the app works locally in VS for Mac but fails in Azure due to this error:

MTOUCH : error MT2002: Failed to resolve "System.Drawing.Color" reference from "System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [/Users/runner/runners/2.164.6/work/1/s/iOS/CatRentalStore.iOS.csproj]

I was having a similar issue with the Android build. I resolved it by switching from the macOS-10.14 hosted build agent to the windows-2019 agent, but that isn't an option with the iOS app.

I've updated packages that may use System.Drawing.Color to the latest stable releases - Acr.UserDialogs, BTProgressHUD, Splat, and Xamarin.Essentials.

I searched the solution source and did not find any direct references to the System.Drawing.Color class.

I also tried specifying the version of Xamarin/Mono to use in the build to match my local version using sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 6_4_0. That caused a different error to occur:

error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
error MSB4018: System.MissingMethodException: Method not found: System.Collections.Generic.IList`1<NuGet.Packaging.Core.PackageDependency> NuGet.ProjectModel.LockFileTargetLibrary.get_Dependencies()

References to this issue:

https://github.com/mono/mono/issues/13483

https://github.com/xamarin/xamarin-macios/pull/6011

https://github.com/aritchie/userdialogs/issues/654

https://github.com/reactiveui/splat/issues/204

Questioner
Tommy Baggett
Viewed
84
ReadyToLearn 2020-02-06 15:30

According to this document:

NET Core 2.2.105 is default on VM images but Mono version 6.0 or greater requires .NET Core 2.2.300+. If you use the Mono 6.0 or greater, you will have to override .NET Core version using .NET Core Tool Installer task. If you use 6.4.0, you need to install at least 2.2.300+ .net core.