Repository navigation
[Xamarin.Android.Build.Tasks] Keep AAR libraries on deploy - #13833
Conversation
During dotnet run, DeployToDevice may rerun _ResolveLibraryProjectImports after a project reference builds. It skips _CategorizeAndroidLibraries, so app-owned @(AndroidLibrary) AARs are absent and native libraries can be removed from the APK. Run _CategorizeAndroidLibraries in CoreResolveReferencesDependsOn before _ResolveAars. Add a device test for dotnet run --no-build. Fixes: #13821 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The test does not pass the harness-selected device to dotnet.Run(), so multiple attached devices can trigger interactive selection or failure before AAR retention is checked.
1 open issue
What changed in this PR
Addresses #13821 by preserving native libraries from app-owned AARs when .NET for Android reruns library import resolution during deployment.
Changes:
- Runs
_CategorizeAndroidLibrariesbefore_ResolveAarsduring reference resolution. - Adds a device regression test that forces import resolution to rerun and checks that
dotnet run --no-buildpreserves the native library in the APK.
| File | Description |
|---|---|
| tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs | Adds the AAR native-library retention regression test. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets | Adds library categorization to the reference-resolution dependency chain. |
Review effort: Balanced
|
/azp run Xamarin.Android-PR |
|
No pipelines are associated with this pull request. |
|
Internal
The public CI (dnceng-public) is offline, so this internal build is the only CI result. |
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed the AAR categorization ordering and its build, deploy, design-time, and per-RID consumers, plus the new native-library deployment test and embedded fixture. The change preserves the AAR native-library imports for DeployToDevice and dotnet run --no-build. No blocking issues found.
Static source review only; no builds or tests executed.

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
5c9398beec89c8d91a77adbb412fa533620452c1↑ Device regression test passed before final device-selection cleanup.
↓ Device test not rerun after cleanup.
dotnet run --no-buildand traced it to skipped categorization during deploy.Fixes: #13821
dotnet runcan remove native libraries from app-owned@(AndroidLibrary)AARs during deploy after a referenced project rebuild. The deploy build reruns_ResolveLibraryProjectImportswithout first categorizing those items.Add
_CategorizeAndroidLibrariesto$(CoreResolveReferencesDependsOn)before_ResolveAars. The regression test checks thatdotnet run --no-buildkeeps the AAR's native library in the APK.Validation:
dotnet-local.cmd build tests\MSBuildDeviceIntegration\MSBuildDeviceIntegration.csproj -c Debug --no-restore -p:EnableSourceLink=false -p:EnableSourceControlManagerQueries=false -v minimalpassed with 0 warnings and 0 errors;git diff --checkpassed. The focused device test passed before the final device-selection cleanup. It was not rerun afterward because four devices are attached and the test now uses normaldotnet rundevice selection.