|
13 | 13 | the patch in some build orderings. This suppression is harmless since we do fix them. --> |
14 | 14 | <AndroidPageSize16KBCompatibilityCheck>false</AndroidPageSize16KBCompatibilityCheck> |
15 | 15 | </PropertyGroup> |
| 16 | + |
16 | 17 | <!-- Patch NuGet-provided .so files that ship with 4 KB ELF alignment to 16 KB. |
17 | 18 | See build/PatchElfPageSize.targets for details. |
18 | 19 | TODO: Remove once ppy.Veldrid.SPIRV ships 16 KB-aligned native libraries. --> |
19 | 20 | <Import Project="$(MSBuildThisFileDirectory)build\PatchElfPageSize.targets" /> |
| 21 | + |
20 | 22 | <!-- Release-only optimisations: AOT for low-latency gameplay, trimming for smaller APK. |
21 | 23 | Suppress trim analysis warnings because the project uses reflection extensively |
22 | 24 | (Newtonsoft.Json, Realm, AutoMapper, RuntimeBinder). --> |
23 | 25 | <PropertyGroup Condition="'$(Configuration)' == 'Release'"> |
24 | 26 | <RunAOTCompilation>true</RunAOTCompilation> |
25 | 27 | <AndroidEnableProfiledAot>true</AndroidEnableProfiledAot> |
26 | 28 | <SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings> |
| 29 | + <PublishTrimmed>true</PublishTrimmed> |
| 30 | + <TrimMode>partial</TrimMode> |
27 | 31 | </PropertyGroup> |
| 32 | + |
| 33 | + <ItemGroup Condition="'$(Configuration)' == 'Release'"> |
| 34 | + <!-- Force Microsoft.CSharp into the trimmer input graph (.NET 10+). --> |
| 35 | + <!-- A bare TrimmerRootAssembly is ignored if the assembly is not in the --> |
| 36 | + <!-- linker's input set; adding this reference ensures it is included. --> |
| 37 | + <PackageReference Include="Microsoft.CSharp" Version="4.7.0" NoWarn="NU1510" /> |
| 38 | + <TrimmerRootAssembly Include="Microsoft.CSharp" RootMode="all" /> |
| 39 | + </ItemGroup> |
| 40 | + |
28 | 41 | <ItemGroup> |
29 | 42 | <!-- IMPORTANT: ppy.osu.Framework.Android v2026.318.0 only ships net8.0-android34.0 assets. |
30 | 43 | NuGet silently falls back to those assets when the app targets net10.0-android (API 36). |
|
33 | 46 | TODO: Remove this comment once ppy.osu.Framework.Android ships net10.0-android assets. --> |
34 | 47 | <PackageReference Include="ppy.osu.Framework.Android" Version="2026.318.0" /> |
35 | 48 | </ItemGroup> |
| 49 | + |
36 | 50 | <PropertyGroup> |
37 | 51 | <!-- Fody does not handle Android build well, and warns when unchanged. |
38 | 52 | Since Realm objects are not declared directly in Android projects, simply disable Fody. --> |
39 | 53 | <DisableFody>true</DisableFody> |
40 | 54 | </PropertyGroup> |
| 55 | + |
| 56 | + <!-- Fix for .NET 10 Android AOT misclassifying non-managed assets in runtime pack. |
| 57 | + This is critical for Android 16 (API 36) which has stricter manifest/parsing rules. --> |
| 58 | + <Target Name="FixRuntimePackAssetTypes" AfterTargets="ResolveRuntimePackAssets;ComputeFilesToPublish;ComputeResolvedFilesToPublishList"> |
| 59 | + <ItemGroup> |
| 60 | + <RuntimePackAsset Update="@(RuntimePackAsset)" Condition="'%(Extension)' != '.dll'"> |
| 61 | + <AssetType>native</AssetType> |
| 62 | + </RuntimePackAsset> |
| 63 | + <ResolvedFileToPublish Update="@(ResolvedFileToPublish)" Condition="'%(Extension)' != '.dll'"> |
| 64 | + <AssetType>native</AssetType> |
| 65 | + </ResolvedFileToPublish> |
| 66 | + </ItemGroup> |
| 67 | + </Target> |
41 | 68 | </Project> |
0 commit comments