Skip to content

[CoreCLR] Exclude diagnostic libraries from release APKs - #11245

Merged
jonathanpeppers merged 3 commits into
mainfrom
dev/simonrozsival/exclude-coreclr-diagnostics-libs
Apr 30, 2026
Merged

jonathanpeppers merged 3 commits into
mainfrom
dev/simonrozsival/exclude-coreclr-diagnostics-libs

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • exclude CoreCLR DAC/DBI diagnostic native libraries from Android APK packaging when debugger support is explicitly disabled
  • update CoreCLR Release arm64 APK descriptor baselines to remove libmscordaccore.so and libmscordbi.so, including PackageSize reductions

APK descriptor size impact

Descriptor Before After Delta
BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc 9,238,298 4,874,730 -4,363,568
BuildReleaseArm64XFormsDotNet.CoreCLR.apkdesc 22,873,019 18,509,451 -4,363,568

The PackageSize delta is exactly the raw size of the two removed APK entries:

Entry Size
lib/arm64-v8a/libmscordaccore.so 2,463,848
lib/arm64-v8a/libmscordbi.so 1,899,720
Total 4,363,568

Local dotnet new maui APK size impact

Local Release publish of a blank dotnet new maui app for .apk (android-arm64):

APK Size Delta vs Mono Delta vs CoreCLR before
CoreCLR Release before 22,039,645 +2,882,672 (+15.0%) -
CoreCLR Release after 20,433,861 +1,276,888 (+6.7%) -1,605,784 (-7.3%)
Mono Release 19,156,973 - -

This saves about 1.53 MiB compressed in the CoreCLR APK and reduces the blank-app CoreCLR-vs-Mono gap from about 2.75 MiB to about 1.22 MiB.

Notes

libmscordbi.so and libmscordaccore.so are present in the CoreCLR runtime pack as native assets, so the Android packaging pipeline currently treats them as framework native libraries and includes them in APKs. Normal Android CoreCLR app startup does not load these libraries; they are debugger/diagnostic sidecars.

The exclusion is gated on DebuggerSupport == false. Android defaults DebuggerSupport=false for optimized Release apps, while Debug builds can leave the property unset; using an explicit false check avoids treating an unset Debug value as disabled. Projects that set DebuggerSupport=true continue to package these libraries.

Local investigation with a blank MAUI CoreCLR R2R app showed that removing both libraries reduced the APK by about 1.5 MiB compressed and the app still installed and cold-launched successfully on an Android device.

Additional local validation with a project-level target matching this PR showed:

  • Debug CoreCLR with packaged assets and unset DebuggerSupport: DAC/DBI remain packaged
  • Release default where DebuggerSupport=false: DAC/DBI are removed
  • Release with DebuggerSupport=true: DAC/DBI remain packaged

Validation

  • git diff --check
  • parsed updated .apkdesc files with jq empty
  • local blank MAUI Debug/Release publishes with binlogs for Debug CoreCLR packaged assets, Release default, and Release DebuggerSupport=true
  • targeted repo test was not run because this clean worktree requires make prepare

@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/exclude-coreclr-diagnostics-libs branch 3 times, most recently from 9801060 to 76bd0c0 Compare April 29, 2026 11:40
CoreCLR Android runtime packs include libmscordbi.so and libmscordaccore.so for debugging/diagnostics, but normal Release app startup does not load them. Exclude these diagnostic native libraries from CoreCLR APK packaging when debug symbols are not requested.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival force-pushed the dev/simonrozsival/exclude-coreclr-diagnostics-libs branch from 76bd0c0 to f66d081 Compare April 29, 2026 11:54
@simonrozsival
simonrozsival marked this pull request as ready for review April 29, 2026 13:28
Copilot AI review requested due to automatic review settings April 29, 2026 13:28
@simonrozsival simonrozsival added Area: CoreCLR Issues that only occur when using CoreCLR. copilot `copilot-cli` or other AIs were used to author this labels Apr 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 reduces CoreCLR Release APK size by excluding the CoreCLR diagnostic sidecar native libraries (DAC/DBI) from APK packaging when debugger support is disabled, and updates the corresponding APK descriptor baselines used by size-regression tests.

Changes:

  • Exclude libmscordaccore.so and libmscordbi.so from CoreCLR native library processing when DebuggerSupport=false.
  • Update CoreCLR Release arm64 .apkdesc baselines to remove the two entries and reflect reduced PackageSize.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets Adds conditional exclusions for DAC/DBI native libraries in CoreCLR when DebuggerSupport is disabled.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.CoreCLR.apkdesc Updates Release arm64 baseline descriptor to remove DAC/DBI entries and adjust PackageSize.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.CoreCLR.apkdesc Updates Release arm64 baseline descriptor to remove DAC/DBI entries and adjust PackageSize.

Comment on lines +297 to +298
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordaccore" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordbi" />
Comment on lines +297 to +298
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordaccore" />
<_ExcludedNativeLibraries Condition=" '$(_AndroidRuntime)' == 'CoreCLR' And '$(DebuggerSupport)' == 'false' " Include="libmscordbi" />

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot let's switch the conditions to '$(AndroidIncludeDebugSymbols)' == 'true' for consisntecy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done in 3381cc7. Switched both conditions from '$(DebuggerSupport)' == 'false' to '$(AndroidIncludeDebugSymbols)' != 'true', consistent with how line 288 gates the Mono debugger component.

…Symbols

Agent-Logs-Url: https://github.com/dotnet/android/sessions/1959d28f-d2ee-4a8e-ac8f-e041b95f1bfa

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
jonathanpeppers merged commit b35fa78 into main Apr 30, 2026
3 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/simonrozsival/exclude-coreclr-diagnostics-libs branch April 30, 2026 19:22
@github-actions github-actions Bot locked and limited conversation to collaborators May 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Area: CoreCLR Issues that only occur when using CoreCLR. copilot `copilot-cli` or other AIs were used to author this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants