Skip to content

fix: Native AOT symbol upload and Android NDK preload without -f, and debug file upload for Android Native AOT builds - #6002

Merged
jamescrosswell merged 5 commits into
mainfrom
fix/single-target-framework-flags
Nov 24, 2026
Merged

jamescrosswell merged 5 commits into
mainfrom
fix/single-target-framework-flags

Conversation

@ric-oliv

@ric-oliv ric-oliv commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Single-target projects, like the ones dotnet new console and dotnet new android create, now behave the same without -f as they already did with it, and Android Native AOT apps upload their debug files:

  • A Native AOT publish of a desktop or server app uploads the native debug files from publish/. It used to upload the managed PDBs from bin/, so Sentry couldn't symbolicate stack traces from those apps. The native files are bigger, so the upload takes longer.
  • Android apps on net10.0-android or later that don't run on Mono get the io.sentry.ndk.preload metadata from fix: prevent redundant native exceptions on Android/CoreCLR #5127.
  • Android Native AOT apps upload their native debug file from bin/ after every Native AOT build, like iOS and Mac Catalyst, with or without -f. With -f or in a multi-targeted MAUI app, the upload used to wait for Publish, so a plain build uploaded nothing. On net11 a publish found nothing either, because publish/ holds only the APK and AAB there. Sentry needs that file for native crashes, and since fix(android): symbolicate managed exceptions from NativeAOT apps #5916 for managed exceptions too.

The cause is import order. Sentry.targets read the _SentryIsNet*OrGreater flags, which Sentry.props sets only when TargetFramework has a value. NuGet imports Sentry.props before the project body, where a single-target project sets TargetFramework. -f worked around it by making TargetFramework a global property. The Native AOT upload broke in 6.7.0, when #5240 replaced a direct TargetFramework comparison with the flag.

Sentry.targets now checks TargetFramework with IsTargetFrameworkCompatible instead, because NuGet imports it after the project body. The flags compare only the version number, so monoandroid90 counted as net9. IsTargetFrameworkCompatible checks the framework too. Nothing reads the net10 and net11 flags any more, so they're removed from Sentry.props. Sentry.Native.targets computes its own net8 and net9 flags after the project body, so it isn't affected.

The Android change has to ship with the -f fix. Single-target Android Native AOT apps only uploaded their debug file because their flags were empty, and the fix alone would have moved them onto the publish/ path. I checked it on a single-target net11.0-android app, with one runtime identifier and with the default two, and on a net10.0-android app with one. I haven't run a MAUI app.

Two other cases change. I checked both on macOS, with sentry-cli uploading to a fake Sentry server:

  • A single-target macOS app with PublishAot now behaves the same as it does with -f. On net11 it uploads the dSYM from publish/. On net10 it uploads nothing, because the macOS workload has no _CopyAotSymbols target, and that was already true with -f. Before, it uploaded only managed PDBs, which don't help with Native AOT stack traces.
  • A single-target library with PublishAot set, referenced by an app being published, stops uploading its managed PDBs during that publish, as multi-targeted libraries already did. The app's native debug file covers the library's code.

On tests:

  • The Native AOT "uploads symbols" case in cli.Tests.ps1 now publishes without --framework and checks that the upload comes from publish/. It fails on main for net10.0 and net11.0. Nothing caught this before, because every test that uploads symbols passes --framework.
  • A new case in cli-maui.Tests.ps1 builds a single-target Android Native AOT app without --framework. It checks that lib<app>.dbg.so gets uploaded and that the manifest has the preload metadata, so it fails without the Android exclusion or with the preload reading the flag again. It runs only on the Linux integration test leg, to keep the macOS and Windows legs short.
  • I also checked the preload by hand on a scratch single-target net10.0-android app with UseMonoRuntime=false.
  • On an API 35 emulator, I ran the managed, Java, native and null reference crash cases from android.Tests.ps1 against a single-target net11.0-android app built without -f, on CoreCLR and on Native AOT. With main's targets, a caught NullReferenceException also sends a SIGSEGV event on both runtimes. With this change it sends one event. No case got worse. On Native AOT, the managed crash case sends two events with and without this change.

Closes #5744

ric-oliv and others added 2 commits November 24, 2026 14:04
The Android workload sets _IsPublishing on every Native AOT build, so Android
apps matched the desktop Native AOT upload settings whenever the version flags
were set, for example with -f or in a multi-targeted MAUI app. Those settings
upload from PublishDir after _CopyAotSymbols or Publish, so a plain build never
ran the upload. On net11, a publish didn't help either, because publish/ holds
only the APK and AAB there and sentry-cli found no debug files.

Android is now excluded from those settings, like iOS and Mac Catalyst. It
takes the managed path, which uploads from OutputPath after Build. By then
native/ already holds the debug file, lib<app>.dbg.so on net11 and
<app>.so.dbg on net10. A new cli-maui case builds a single-target Android
Native AOT app and checks that the debug file gets uploaded.

Refs #5744

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Native AOT upload settings and SetAndroidNdkPreload read the
_SentryIsNet*OrGreater flags, which Sentry.props sets only when TargetFramework
has a value. NuGet imports Sentry.props before the project body, and a
single-target project sets TargetFramework in that body, so the flags stayed
empty unless -f passed TargetFramework as a global property. The Native AOT
check compared TargetFramework directly until #5240.

As a result, a Native AOT publish fell back to the managed upload, which sends
the managed PDBs from bin/ instead of the native debug files from publish/.
SetAndroidNdkPreload skipped the io.sentry.ndk.preload metadata for Android
apps that don't run on Mono.

Sentry.targets now checks TargetFramework with IsTargetFrameworkCompatible
where it needs a version. NuGet imports it after the project body, where
TargetFramework has its value. The flags compared only the version number, so
monoandroid90 counted as net9. IsTargetFrameworkCompatible checks the framework
too. Nothing reads the net10 and net11 flags any more, so Sentry.props drops
them.

Every integration test that uploads symbols passed --framework, so none of them
caught this. The Native AOT "uploads symbols" test now publishes without it,
through a new -OmitFrameworkArgument switch on RunDotnetWithSentryCLI, and
checks that the upload comes from publish/. The cli-maui Android Native AOT case
now builds without --framework too and checks the manifest for the preload
metadata.

Fixes #5744

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit c167f2d.

Main concerns: reach, dependencies customers inherit, public contract.

Rules that block low also fired:

  • R6: build or release configuration changed: src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets, src/Sentry/buildTransitive/Sentry.props, src/Sentry/buildTransitive/Sentry.targets

This label is a hint for reviewers, not an approval.

@sentry-junior sentry-junior Bot 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.

Good to approve, with optional comments

Fixes the cause from #5744: Sentry.targets now checks TargetFramework with IsTargetFrameworkCompatible, after the project body sets it, instead of reading flags that Sentry.props computes too early. It also moves Android Native AOT onto the build-time upload path, so the fix doesn't regress single-target Android apps.

  • Optional: integration-test/cli-maui.Tests.ps1 runs the new Android Native AOT case only for $latestFramework with one RID. The net10.0-android lower bound of the preload condition and the default multi-RID Android build are covered only by the manual checks in the description.
  • Optional: src/Sentry/buildTransitive/Sentry.targets:170-171 still says the TFM conditions stay in sync with Sentry.Native.targets, which keeps the version-number flags (Sentry.Native.targets:12-16). The two now use different checks. That's harmless today because Sentry.Native.targets gates on the RID, but the note no longer matches the code.
  • Optional: Sentry.props ships in the package, so a consumer project that read _SentryIsNet10OrGreater / _SentryIsNet11OrGreater now gets an empty value with no warning. They're underscore-prefixed, so the risk is low.

This is an automated preliminary review.

@ric-oliv ric-oliv changed the title fix(msbuild): Native AOT symbol upload and the Android NDK preload work without -f, and Android Native AOT builds upload debug files fix: Native AOT symbol upload and NDK preload in single-target projects Nov 24, 2026
@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.17%. Comparing base (d3afb0e) to head (c167f2d).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6002      +/-   ##
==========================================
+ Coverage   77.92%   78.17%   +0.25%     
==========================================
  Files         535      537       +2     
  Lines       19831    20062     +231     
  Branches     3967     4032      +65     
==========================================
+ Hits        15453    15684     +231     
  Misses       3534     3534              
  Partials      844      844              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sentry.targets no longer reads _SentryIsNet10OrGreater or
_SentryIsNet11OrGreater, but Sentry.props ships in the package, so a project
outside the SDK might read them. Removing them would give that project an
empty value with no warning.

Refs #5744

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 24, 2026
The notes said the target framework conditions in Sentry.targets and
Sentry.Native.targets are kept the same. Sentry.targets now uses
IsTargetFrameworkCompatible and Sentry.Native.targets still uses its own
version flags, so what the two share is the net8.0 minimum. The note in
Sentry.Native.targets also pointed at a buildTransitive/Sentry.Native.targets
that doesn't exist, instead of Sentry.targets.

Refs #5744

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 24, 2026
@ric-oliv ric-oliv changed the title fix: Native AOT symbol upload and NDK preload in single-target projects fix: Native AOT symbol upload and Android NDK preload without -f, and debug file upload for Android Native AOT builds Nov 24, 2026
@ric-oliv
ric-oliv marked this pull request as ready for review November 24, 2026 15:53
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 24, 2026
@jamescrosswell

Copy link
Copy Markdown
Collaborator

The Native AOT upload broke in 6.7.0, when #5240 replaced a direct TargetFramework comparison with the flag.

Dang - one small refactoring and we never caught it. Good to have some tests for this now.

@jamescrosswell jamescrosswell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nothing reads _SentryIsNet10OrGreater / _SentryIsNet11OrGreater after this change, so let's drop them from Sentry.props rather than keep them. The _ prefix marks them as internal, and in a single-target project they'd be empty anyway, so anyone reading them would get the wrong answer. _SentryIsNet8OrGreater / _SentryIsNet9OrGreater need to stay: the repo's own Directory.Build.props files and Sentry.Native.targets still read them.

Nothing reads _SentryIsNet10OrGreater or _SentryIsNet11OrGreater any more.
The underscore marks them as internal, and in a single-target project they
are empty anyway, so keeping them for outside readers bought nothing.

This reverts commit 24a4b80.

Refs #5744

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Nov 24, 2026
@jamescrosswell
jamescrosswell merged commit 2412d9c into main Nov 24, 2026
84 of 85 checks passed
@jamescrosswell
jamescrosswell deleted the fix/single-target-framework-flags branch November 24, 2026 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-target projects built without -f skip Native AOT symbol upload and the Android NDK preload

2 participants