From 684642a92600682415d9cb0d9fc45c51136a91b4 Mon Sep 17 00:00:00 2001 From: monojenkins Date: Wed, 11 Sep 2019 01:58:24 -0400 Subject: [PATCH] [xcode11] [msbuild][xm][xi] Fix building with netstandard libraries (#6959) * [msbuild] Use task assembly path via a property Xamarin.Mac.Common.ImplicitFacade.msbuild.targets: $(_NETBuildExtensionsTaskAssembly) * [msbuild] Fix path to NET.Build.Extensions task assembly .. which is no longer available for `net46`. Instead use the latest `net472` path. The incorrect path effectively disabled the `GetDependsOnNETStandard` task, causing the issue. Partially fixes https://github.com/xamarin/xamarin-macios/issues/6552 . * [msbuild] Fix XM builds which use netstandard libraries. `Xamarin.Mac.Common.ImplicitFacade.msbuild.targets`: `ImplicitlyExpandDesignTimeFacades` adds a reference to `netstandard.dll` by expanding the facades, if any of the references depend on it. Usually, this gets handled by msbuild SDKs but in case of XM, this doesn't happen in all cases. So, we need to scan the references for a `netstandard` dependency. The `ResolveAssemblyReference` task does this for us and populates `$(_DependsOnNETStandard)` property. If it does not, then we use `GetDependsOnNETStandard` task to get the same information. Issue: - the target incorrectly uses `$(DependsOnNETStandard)` instead of `($_DependsOnNETStandard)`. - Fixing that means that condition `$(_DependsOnNETStandard) == ''` fails whenever `ResolveAssemblyReference` task runs (setting the property to `true` or `false`), causing `$(XM_DependsOnNETStandard)` to be unset. - thus failing the following logic to expand the facades when `$(_DependsOnNETStandard) == true` So, we use the `$(_DependsOnNETStandard)` as the default value for `$(XM_DependsOnNETStandard)`, so that it is correctly set to `true`, irrespective of how we got that information, allowing us to correctly expand facades when required. Partially fixes https://github.com/xamarin/xamarin-macios/issues/6552 . * [msbuild] Fix XI builds which use netstandard libraries. `Xamarin.iOS.Common.targets`: Issue: - the target incorrectly uses `$(DependsOnNETStandard)` instead of `($_DependsOnNETStandard)`. - Fixing that means that condition `$(_DependsOnNETStandard) == ''` fails whenever `ResolveAssemblyReference` task runs (setting the property to `true` or `false`), causing `$(XI_DependsOnNETStandard)` to be unset. - thus failing the following logic to expand the facades when `$(_DependsOnNETStandard) == true` So, we use the `$(_DependsOnNETStandard)` as the default value for `$(XI_DependsOnNETStandard)`, so that it is correctly set to `true`, irrespective of how we got that information, allowing us to correctly expand facades when required. Prompted by: https://github.com/xamarin/xamarin-macios/issues/6552 --- ...n.Mac.Common.ImplicitFacade.msbuild.targets | 18 ++++++++++++++---- .../Xamarin.iOS.Common.targets | 10 +++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.ImplicitFacade.msbuild.targets b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.ImplicitFacade.msbuild.targets index ee2d88f931..ec6cbba795 100644 --- a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.ImplicitFacade.msbuild.targets +++ b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.ImplicitFacade.msbuild.targets @@ -30,14 +30,16 @@ Copyright (c) 2017 Microsoft Corp. (www.microsoft.com) $(ImplicitlyExpandDesignTimeFacadesDependsOn); GetReferenceAssemblyPaths + + <_NETBuildExtensionsTaskAssembly>$(MSBuildExtensionsPath)\Microsoft\Microsoft.NET.Build.Extensions\tools\net472\Microsoft.NET.Build.Extensions.Tasks.dll + Condition="'$(IsXBuild)' != 'true' and Exists('$(_NETBuildExtensionsTaskAssembly)')" + AssemblyFile="$(_NETBuildExtensionsTaskAssembly)" /> @@ -50,6 +52,14 @@ Copyright (c) 2017 Microsoft Corp. (www.microsoft.com) <_HasReferenceToSystemRuntime Condition="'$(DependsOnSystemRuntime)' == 'true' or '%(_ResolvedProjectReferencePaths.TargetPlatformIdentifier)' == 'Portable'">true true + + + $(_DependsOnNETStandard) diff --git a/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets b/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets index cb72bb480a..ce9b01c5eb 100644 --- a/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets +++ b/msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets @@ -178,6 +178,14 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved. or '%(ReferenceDependencyPaths.Filename)' == 'System.Runtime'">true true + + + $(_DependsOnNETStandard)