Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ _ResolveAssemblies MSBuild target.
</PropertyGroup>
<ItemGroup>
<_ResolvedNativeLibraries Include="@(ResolvedFileToPublish)" Condition=" '%(ResolvedFileToPublish.Extension)' == '.so' " />
<!-- Exclude native libraries from non-Android RIDs (e.g. runtimes/linux-x64/native/).
The .NET SDK sets RuntimeIdentifier metadata to the current Android RID on all
ResolvedFileToPublish items, causing non-Android .so files to pass ABI checks
downstream. Check the file path for non-Android runtimes/ directories.
Note: both 'android-*' and 'linux-bionic-*' RIDs are valid Android targets. -->
<_ResolvedNativeLibraries Remove="@(_ResolvedNativeLibraries)"
Condition=" $([System.String]::new('%(Identity)').Replace('\','/').Contains('/runtimes/')) And
!$([System.String]::new('%(Identity)').Replace('\','/').Contains('/runtimes/android')) And
!$([System.String]::new('%(Identity)').Replace('\','/').Contains('/runtimes/linux-bionic')) " />
</ItemGroup>
<ItemGroup>
<_MonoComponent Condition=" '$(AndroidEnableProfiler)' == 'true' " Include="diagnostics_tracing" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,38 @@ public void XA0141ErrorIsRaised ([Values] bool isRelease, [Values] AndroidRuntim
}
}

[Test]
public void NonAndroidNativeLibrariesDoNotProduceWarnings ()
{
var proj = new XamarinAndroidApplicationProject ();
// Create a dummy .so at a path mimicking a non-Android NuGet native library
proj.OtherBuildItems.Add (new BuildItem ("None", "runtimes/linux-x64/native/libFake.so") {
BinaryContent = () => new byte [128],
});
// Inject it into ResolvedFileToPublish with RuntimeIdentifier=android-arm64,
// simulating what the .NET SDK does for packages like Microsoft.Testing.Extensions.CodeCoverage
proj.Imports.Add (new Import ("non-android-so.targets") {
TextContent = () =>
"""
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Target Name="_InjectFakeLinuxSo" BeforeTargets="_IncludeNativeSystemLibraries">
<ItemGroup>
<ResolvedFileToPublish Include="$(MSBuildProjectDirectory)/runtimes/linux-x64/native/libFake.so">
<RuntimeIdentifier>android-arm64</RuntimeIdentifier>
<NuGetPackageId>FakePackage</NuGetPackageId>
<NuGetPackageVersion>1.0.0</NuGetPackageVersion>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
</Project>
""",
});
using var b = CreateApkBuilder ();
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
b.AssertHasNoWarnings ();
}

static IEnumerable<object[]> Get_XA1037PropertyDeprecatedWarningData ()
{
var ret = new List<object[]> ();
Expand Down