[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
This commit is contained in:
monojenkins 2019-09-11 01:58:24 -04:00 коммит произвёл Rolf Bjarne Kvinge
Родитель d9d6c9d800
Коммит 684642a926
2 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -30,14 +30,16 @@ Copyright (c) 2017 Microsoft Corp. (www.microsoft.com)
$(ImplicitlyExpandDesignTimeFacadesDependsOn);
GetReferenceAssemblyPaths
</ImplicitlyExpandDesignTimeFacadesDependsOn>
<_NETBuildExtensionsTaskAssembly>$(MSBuildExtensionsPath)\Microsoft\Microsoft.NET.Build.Extensions\tools\net472\Microsoft.NET.Build.Extensions.Tasks.dll</_NETBuildExtensionsTaskAssembly>
</PropertyGroup>
<!-- Implicitly references all portable design-time facades if the user is referencing a System.Runtime-based portable library -->
<UsingTask
TaskName="GetDependsOnNETStandard"
Condition="'$(IsXBuild)' != 'true' and Exists('$(MSBuildExtensionsPath)\Microsoft\Microsoft.NET.Build.Extensions\tools\net46\Microsoft.NET.Build.Extensions.Tasks.dll')"
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\Microsoft.NET.Build.Extensions\tools\net46\Microsoft.NET.Build.Extensions.Tasks.dll" />
Condition="'$(IsXBuild)' != 'true' and Exists('$(_NETBuildExtensionsTaskAssembly)')"
AssemblyFile="$(_NETBuildExtensionsTaskAssembly)" />
<Target Name="ImplicitlyExpandDesignTimeFacades" DependsOnTargets="$(ImplicitlyExpandDesignTimeFacadesDependsOn)">
<ItemGroup>
@ -50,6 +52,14 @@ Copyright (c) 2017 Microsoft Corp. (www.microsoft.com)
<_HasReferenceToSystemRuntime Condition="'$(DependsOnSystemRuntime)' == 'true' or '%(_ResolvedProjectReferencePaths.TargetPlatformIdentifier)' == 'Portable'">true</_HasReferenceToSystemRuntime>
<XM_NETStandardInbox Condition="'$(XM_NETStandardInbox)' == '' and Exists('%(XM_InboxNETStandardFolders.Identity)\netstandard.dll')">true</XM_NETStandardInbox>
<!--
This is `true` if any of the references depends on `netstandard`.
In cases where `ResolveAssemblyReference` task does get run, it populates `$(_DependsOnNETStandard)` property, so we don't
need to check this again.
-->
<XM_DependsOnNETStandard Condition="'$(XM_DependsOnNETStandard)' == ''">$(_DependsOnNETStandard)</XM_DependsOnNETStandard>
</PropertyGroup>
<!--
@ -63,8 +73,8 @@ Copyright (c) 2017 Microsoft Corp. (www.microsoft.com)
If $(_HasReferenceToSystemRuntime) is true, then the facades are going to be expanded anyway, so don't run this.
-->
<GetDependsOnNETStandard
Condition="'$(_HasReferenceToSystemRuntime)' != 'true' and '$(IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(XM_CandidateNETStandardReferences)' != ''
and Exists('$(MSBuildExtensionsPath)\Microsoft\Microsoft.NET.Build.Extensions\tools\net46\Microsoft.NET.Build.Extensions.Tasks.dll')"
Condition="'$(_HasReferenceToSystemRuntime)' != 'true' and '$(IsXBuild)' != 'true' and '$(XM_DependsOnNETStandard)' == '' and '@(XM_CandidateNETStandardReferences)' != ''
and Exists('$(_NETBuildExtensionsTaskAssembly)')"
References="@(XM_CandidateNETStandardReferences)">
<Output TaskParameter="DependsOnNETStandard" PropertyName="XM_DependsOnNETStandard" />
</GetDependsOnNETStandard>

Просмотреть файл

@ -178,6 +178,14 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
or '%(ReferenceDependencyPaths.Filename)' == 'System.Runtime'">true</_HasReferenceToSystemRuntime>
<XI_NETStandardInbox Condition="'$(XI_NETStandardInbox)' == '' and Exists('%(XI_InboxNETStandardFolders.Identity)\netstandard.dll')">true</XI_NETStandardInbox>
<!--
This is `true` if any of the references depends on `netstandard`.
In cases where `ResolveAssemblyReference` task does get run, it populates `$(_DependsOnNETStandard)` property, so we don't
need to check this again.
-->
<XI_DependsOnNETStandard Condition="'$(XI_DependsOnNETStandard)' == ''">$(_DependsOnNETStandard)</XI_DependsOnNETStandard>
</PropertyGroup>
<!--
@ -191,7 +199,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
If $(_HasReferenceToSystemRuntime) is true, then the facades are going to be expanded anyway, so don't run this.
-->
<GetDependsOnNETStandard
Condition="'$(_HasReferenceToSystemRuntime)' != 'true' and '$(IsXBuild)' != 'true' and '$(DependsOnNETStandard)' == '' and '@(XI_CandidateNETStandardReferences)' != ''"
Condition="'$(_HasReferenceToSystemRuntime)' != 'true' and '$(IsXBuild)' != 'true' and '$(XI_DependsOnNETStandard)' == '' and '@(XI_CandidateNETStandardReferences)' != ''"
References="@(XI_CandidateNETStandardReferences)">
<Output TaskParameter="DependsOnNETStandard" PropertyName="XI_DependsOnNETStandard" />
</GetDependsOnNETStandard>