Skip to content

[xabt] Filter non-Android .so files from _ResolvedNativeLibraries#10936

Open
jonathanpeppers wants to merge 2 commits intomainfrom
dev/peppers/linux-so-files
Open

[xabt] Filter non-Android .so files from _ResolvedNativeLibraries#10936
jonathanpeppers wants to merge 2 commits intomainfrom
dev/peppers/linux-so-files

Conversation

@jonathanpeppers
Copy link
Member

NuGet packages like Microsoft.Testing.Extensions.CodeCoverage ship native .so files under runtimes/linux-x64/native/. The .NET SDK stamps RuntimeIdentifier=android-arm64 metadata on all ResolvedFileToPublish items during inner builds, causing ProcessNativeLibraries to treat these non-Android libraries as valid Android native libs. This leads to spurious XA0141 warnings about 16 KB page alignment.

Use %(PathInPackage) metadata to detect the actual source RID and exclude .so files from non-Android runtimes (linux-x64, linux-musl-x64, osx-x64, win-x64, etc.) while preserving android-* and linux-bionic-* RIDs which are valid Android targets.

NuGet packages like Microsoft.Testing.Extensions.CodeCoverage ship
native .so files under runtimes/linux-x64/native/. The .NET SDK stamps
RuntimeIdentifier=android-arm64 metadata on all ResolvedFileToPublish
items during inner builds, causing ProcessNativeLibraries to treat
these non-Android libraries as valid Android native libs. This leads
to spurious XA0141 warnings about 16 KB page alignment.

Use %(PathInPackage) metadata to detect the actual source RID and
exclude .so files from non-Android runtimes (linux-x64, linux-musl-x64,
osx-x64, win-x64, etc.) while preserving android-* and linux-bionic-*
RIDs which are valid Android targets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 13, 2026 17:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Android SDK MSBuild assembly/native resolution pipeline to avoid treating non-Android .so runtime assets (e.g., runtimes/linux-x64/native/*.so from NuGet packages) as Android native libraries, preventing downstream ABI/alignment checks from producing spurious XA0141 warnings.

Changes:

  • Adds a filtering step for _ResolvedNativeLibraries based on %(PathInPackage) to exclude .so files coming from non-Android runtime folders under runtimes/.
  • Explicitly preserves runtimes/android* and runtimes/linux-bionic* native assets as valid Android targets.

Use %(Identity) path instead of %(PathInPackage) metadata to filter
non-Android .so files from _ResolvedNativeLibraries, since runtime
pack items don't define PathInPackage (causing MSB4096).

Add NonAndroidNativeLibrariesDoNotProduceWarnings test that injects a
fake linux-x64 .so into ResolvedFileToPublish with RuntimeIdentifier
set to android-arm64, verifying the filter prevents spurious warnings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants