From f5cdcbca098bdcd9e0756c5b11c436efe20b96d7 Mon Sep 17 00:00:00 2001
From: Jonathan Peppers <jonathan.peppers@microsoft.com>
Date: Fri, 9 Sep 2022 08:28:30 -0500
Subject: [PATCH] [illink] set `$(TrimmerRemoveSymbols)` by default

Fixes: https://github.com/xamarin/xamarin-android/issues/7302
Context: https://github.com/dotnet/linker/issues/2203
Context: https://github.com/dotnet/runtime/issues/67660
Context: https://github.com/xamarin/xamarin-android/pull/6598

This partially backports 745214d.

In addition to this backport to dotnet/runtime/release/6.0:

https://github.com/dotnet/runtime/pull/75311

We also have another change in .NET 7 that opts into
`$(TrimmerRemoveSymbols)` by default for `Release` builds. This allows
the .NET 7 linker to have stable MVIDs for assemblies for each
architecture.

There may potentially be a dotnet/linker issue here to look into
further. However, this seems to be the best fix for getting .NET 6
projects building under .NET 7 at the moment.
---
 .../targets/Microsoft.Android.Sdk.ILLink.targets                 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
index 8bcdb7f64b3..67d1bbba119 100644
--- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
+++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.ILLink.targets
@@ -14,6 +14,7 @@ This file contains the .NET 5-specific targets to customize ILLink
       AfterTargets="ComputeResolvedFilesToPublishList"
       DependsOnTargets="GetReferenceAssemblyPaths;_CreatePropertiesCache">
     <PropertyGroup>
+      <TrimmerRemoveSymbols Condition=" '$(AndroidIncludeDebugSymbols)' != 'true' ">true</TrimmerRemoveSymbols>
       <!--
         Used for the <ILLink DumpDependencies="$(_TrimmerDumpDependencies)" /> value:
         https://github.com/dotnet/sdk/blob/a5393731b5b7b225692fff121f747fbbc9e8b140/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.ILLink.targets#L150
