Repository navigation
fix: Native AOT symbol upload and Android NDK preload without -f, and debug file upload for Android Native AOT builds - #6002
Conversation
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]>
PR risk: mediumFor commit Main concerns: reach, dependencies customers inherit, public contract. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
There was a problem hiding this comment.
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.ps1runs the new Android Native AOT case only for$latestFrameworkwith one RID. Thenet10.0-androidlower 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-171still says the TFM conditions stay in sync withSentry.Native.targets, which keeps the version-number flags (Sentry.Native.targets:12-16). The two now use different checks. That's harmless today becauseSentry.Native.targetsgates on the RID, but the note no longer matches the code. - Optional:
Sentry.propsships in the package, so a consumer project that read_SentryIsNet10OrGreater/_SentryIsNet11OrGreaternow gets an empty value with no warning. They're underscore-prefixed, so the risk is low.
This is an automated preliminary review.
-f, and Android Native AOT builds upload debug files
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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]>
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]>
-f, and debug file upload for Android Native AOT builds
Dang - one small refactoring and we never caught it. Good to have some tests for this now. |
jamescrosswell
left a comment
There was a problem hiding this comment.
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]>
Single-target projects, like the ones
dotnet new consoleanddotnet new androidcreate, now behave the same without-fas they already did with it, and Android Native AOT apps upload their debug files:publish/. It used to upload the managed PDBs frombin/, so Sentry couldn't symbolicate stack traces from those apps. The native files are bigger, so the upload takes longer.net10.0-androidor later that don't run on Mono get theio.sentry.ndk.preloadmetadata from fix: prevent redundant native exceptions on Android/CoreCLR #5127.bin/after every Native AOT build, like iOS and Mac Catalyst, with or without-f. With-for in a multi-targeted MAUI app, the upload used to wait forPublish, so a plain build uploaded nothing. On net11 a publish found nothing either, becausepublish/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.targetsread the_SentryIsNet*OrGreaterflags, whichSentry.propssets only whenTargetFrameworkhas a value. NuGet importsSentry.propsbefore the project body, where a single-target project setsTargetFramework.-fworked around it by makingTargetFrameworka global property. The Native AOT upload broke in 6.7.0, when #5240 replaced a directTargetFrameworkcomparison with the flag.Sentry.targetsnow checksTargetFrameworkwithIsTargetFrameworkCompatibleinstead, because NuGet imports it after the project body. The flags compare only the version number, somonoandroid90counted as net9.IsTargetFrameworkCompatiblechecks the framework too. Nothing reads the net10 and net11 flags any more, so they're removed fromSentry.props.Sentry.Native.targetscomputes its own net8 and net9 flags after the project body, so it isn't affected.The Android change has to ship with the
-ffix. 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 thepublish/path. I checked it on a single-targetnet11.0-androidapp, with one runtime identifier and with the default two, and on anet10.0-androidapp 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:
PublishAotnow behaves the same as it does with-f. On net11 it uploads the dSYM frompublish/. On net10 it uploads nothing, because the macOS workload has no_CopyAotSymbolstarget, and that was already true with-f. Before, it uploaded only managed PDBs, which don't help with Native AOT stack traces.PublishAotset, 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:
cli.Tests.ps1now publishes without--frameworkand checks that the upload comes frompublish/. It fails onmainfor net10.0 and net11.0. Nothing caught this before, because every test that uploads symbols passes--framework.cli-maui.Tests.ps1builds a single-target Android Native AOT app without--framework. It checks thatlib<app>.dbg.sogets 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.net10.0-androidapp withUseMonoRuntime=false.android.Tests.ps1against a single-targetnet11.0-androidapp built without-f, on CoreCLR and on Native AOT. Withmain's targets, a caughtNullReferenceExceptionalso sends aSIGSEGVevent 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