Commit 6469db8
Fix XALNS7015: run _LinkAssembliesNoShrink before R2R in non-trimmed CoreCLR builds
In non-trimmed CoreCLR Release builds, PublishReadyToRun=true causes
the inner build to compile IL assemblies to R2R images (via crossgen2)
before _LinkAssembliesNoShrink runs. R2R assemblies have the ILONLY PE
flag cleared, so when FixAbstractMethodsStep detects a missing abstract
method and marks the assembly modified, SaveChangedAssemblyStep calls
assembly.Write() via Mono.Cecil, which throws:
NotSupportedException: Writing mixed-mode assemblies is not supported
The fix restructures _LinkAssembliesNoShrink to run inside the inner
build (BeforeTargets=_PrepareForReadyToRunCompilation) so assembly
modifications happen before R2R compilation:
- Xamarin.Android.Common.targets: Rewrite _LinkAssembliesNoShrink to
run in the inner build. It copies assemblies to an intermediate
directory (linked-noshrink/) instead of modifying in-place, since
ResolvedFileToPublish items may point to shared locations (NuGet
cache, runtime packs). After the task runs, ResolvedFileToPublish
is updated to point to the intermediate copies. Abi metadata is
computed via RuntimeIdentifierToAbi since _ResolveAndroidTooling
doesn't run in the inner build.
- Microsoft.Android.Sdk.AssemblyResolution.targets: In
_PrepareAssemblies, populate _ResolvedAssemblies unconditionally
from @(ResolvedAssemblies) instead of redirecting through the
intermediate directory for non-trimmed builds.
- Remove Assert.Ignore workarounds in BuildTest and LinkerTests for
the CoreCLR Release non-trimmed case.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 12dd07b commit 6469db8
File tree
4 files changed
+51
-55
lines changed- src/Xamarin.Android.Build.Tasks
- Microsoft.Android.Sdk/targets
- Tests/Xamarin.Android.Build.Tests
- Tasks
4 files changed
+51
-55
lines changedLines changed: 6 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
210 | 216 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
218 | 220 | | |
219 | 221 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | 222 | | |
225 | 223 | | |
226 | 224 | | |
| |||
Lines changed: 0 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2178 | 2178 | | |
2179 | 2179 | | |
2180 | 2180 | | |
2181 | | - | |
2182 | | - | |
2183 | | - | |
2184 | | - | |
2185 | | - | |
2186 | | - | |
2187 | | - | |
2188 | | - | |
2189 | | - | |
2190 | | - | |
2191 | | - | |
2192 | | - | |
2193 | | - | |
2194 | | - | |
2195 | | - | |
2196 | 2181 | | |
2197 | 2182 | | |
2198 | 2183 | | |
| |||
Lines changed: 0 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | 472 | | |
489 | 473 | | |
490 | 474 | | |
| |||
Lines changed: 45 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1419 | 1419 | | |
1420 | 1420 | | |
1421 | 1421 | | |
1422 | | - | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
1423 | 1447 | | |
1424 | | - | |
1425 | | - | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
1426 | 1452 | | |
1427 | | - | |
1428 | 1453 | | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | 1454 | | |
1435 | 1455 | | |
1436 | 1456 | | |
1437 | 1457 | | |
1438 | 1458 | | |
1439 | 1459 | | |
1440 | 1460 | | |
1441 | | - | |
1442 | | - | |
1443 | | - | |
1444 | | - | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
1445 | 1465 | | |
1446 | 1466 | | |
1447 | 1467 | | |
1448 | 1468 | | |
1449 | 1469 | | |
1450 | 1470 | | |
1451 | 1471 | | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
1452 | 1477 | | |
1453 | | - | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
1454 | 1481 | | |
1455 | 1482 | | |
1456 | 1483 | | |
1457 | 1484 | | |
1458 | 1485 | | |
1459 | | - | |
1460 | 1486 | | |
1461 | 1487 | | |
1462 | 1488 | | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
1463 | 1492 | | |
1464 | 1493 | | |
1465 | 1494 | | |
| |||
2881 | 2910 | | |
2882 | 2911 | | |
2883 | 2912 | | |
2884 | | - | |
| 2913 | + | |
2885 | 2914 | | |
2886 | 2915 | | |
2887 | 2916 | | |
| |||
0 commit comments