Skip to content

Commit 45b12a5

Browse files
authored
Merge pull request #225 from winnerspiros/copilot/check-last-build-failure
Android APK: make FixRuntimePackAssetTypes actually strip desktop-RID native `.so` files
2 parents dca84a6 + b2ca976 commit 45b12a5

1 file changed

Lines changed: 41 additions & 19 deletions

File tree

osu.Android.props

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,50 @@
9393
libbass*.so coming from ppy.osu.Framework.Android's AAR (jni/arm64-v8a/). The Linux ELF
9494
is linked against glibc and cannot be loaded by Android's bionic dynamic linker, which
9595
surfaces at startup as System.DllNotFoundException: bass from AudioManager..ctor →
96-
ManagedBass.Bass.get_DeviceCount, immediately crashing the app. -->
96+
ManagedBass.Bass.get_DeviceCount, immediately crashing the app.
97+
98+
Implementation notes:
99+
* Uses a two-step item helper list + Remove-by-identity pattern, which batches
100+
over item metadata reliably (an earlier inline `Remove="@(X)" Condition="…"`
101+
with a nested OR of Replace/Contains calls silently no-op'd — the Linux libbass
102+
leaked into the APK in build v2026.421.144).
103+
* Uses a single inverted match: any `.so` under `/runtimes/<rid>/native/` whose
104+
RID does not start with `android` is stripped. This covers every non-Android
105+
desktop/mobile RID in one rule and is future-proof against new RIDs.
106+
* The path match uses forward-slash normalisation with the doubled-backslash
107+
escape `'\\'` required inside MSBuild property-function string literals
108+
(the previous `'\'` form is ambiguous to the expression parser).
109+
* Applied to `ResolvedFileToPublish` (the primary input to the .NET Android SDK's
110+
publish step) and also to `ReferenceCopyLocalPaths` / `RuntimeCopyLocalItems`
111+
in case a NuGet package flows native assets through those collections. -->
97112
<Target Name="FixRuntimePackAssetTypes" AfterTargets="ResolveRuntimePackAssets;ComputeFilesToPublish;ComputeResolvedFilesToPublishList"
98113
Condition="'$(Configuration)' == 'Release'">
99114
<ItemGroup>
100-
<!-- Strip desktop/iOS runtime .so files from the Android publish set entirely.
101-
Match path components for any non-Android RID known to ship .so files.
102-
Path normalisation handles both Windows (\) and Unix (/) separators. -->
103-
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)"
104-
Condition="'%(Extension)' == '.so'
105-
AND ($([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/linux-'))
106-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/linux/'))
107-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/osx-'))
108-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/osx/'))
109-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/ios-'))
110-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/ios/'))
111-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/maccatalyst-'))
112-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/win-'))
113-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/win/'))
114-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/browser-'))
115-
OR $([System.String]::Copy('%(Identity)').Replace('\','/').Contains('/runtimes/freebsd-')))" />
116-
<!-- Only mark Android-RID runtime pack assets as native. RuntimePackAsset items carry
117-
an explicit RuntimeIdentifier metadata, so this filter is exact. -->
115+
<!-- Build filter lists of non-Android runtime .so files. The two-step pattern
116+
(Include into helper list, then Remove by identity) is more reliable than a
117+
conditional Remove because MSBuild batches per-item on metadata references
118+
in the helper list's Condition, and the subsequent Remove is an unconditional
119+
identity match. -->
120+
<_DesktopNativeToStripFromPublish Include="@(ResolvedFileToPublish)"
121+
Condition="'%(Extension)' == '.so'
122+
AND $([System.String]::Copy('%(Identity)').Replace('\\','/').Contains('/runtimes/'))
123+
AND !$([System.String]::Copy('%(Identity)').Replace('\\','/').Contains('/runtimes/android'))" />
124+
<ResolvedFileToPublish Remove="@(_DesktopNativeToStripFromPublish)" />
125+
126+
<_DesktopNativeToStripFromRefCopy Include="@(ReferenceCopyLocalPaths)"
127+
Condition="'%(Extension)' == '.so'
128+
AND $([System.String]::Copy('%(Identity)').Replace('\\','/').Contains('/runtimes/'))
129+
AND !$([System.String]::Copy('%(Identity)').Replace('\\','/').Contains('/runtimes/android'))" />
130+
<ReferenceCopyLocalPaths Remove="@(_DesktopNativeToStripFromRefCopy)" />
131+
132+
<_DesktopNativeToStripFromRuntimeCopy Include="@(RuntimeCopyLocalItems)"
133+
Condition="'%(Extension)' == '.so'
134+
AND $([System.String]::Copy('%(Identity)').Replace('\\','/').Contains('/runtimes/'))
135+
AND !$([System.String]::Copy('%(Identity)').Replace('\\','/').Contains('/runtimes/android'))" />
136+
<RuntimeCopyLocalItems Remove="@(_DesktopNativeToStripFromRuntimeCopy)" />
137+
138+
<!-- Only mark Android-RID runtime pack assets as native. RuntimePackAsset items
139+
carry an explicit RuntimeIdentifier metadata, so this filter is exact. -->
118140
<RuntimePackAsset Update="@(RuntimePackAsset)"
119141
Condition="'%(Extension)' == '.so'
120142
AND $([System.String]::Copy('%(RuntimeIdentifier)').StartsWith('android'))">

0 commit comments

Comments
 (0)