Skip to content

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

Done

Description

@ric-oliv

Sentry.props sets _SentryIsNet8OrGreater and _SentryIsNet10OrGreater only when TargetFramework has a value. NuGet imports Sentry.props before the project body, and a project with a single <TargetFramework> sets it later, in that body. Both flags stay empty unless -f passes TargetFramework as a global property. dotnet new console creates a project like that, and most people build and publish it without -f.

Two parts of Sentry.targets read these flags:

Native AOT

The test app is an osx-arm64 console app that targets net10.0 and sets PublishAot, SentryUploadSymbols, SentryCreateRelease and SentrySetCommits. A fake sentry-cli logged what dotnet publish -c Release asked it to upload with main's targets:

SDK Without -f With -f net10.0, or with the fix below
.NET 10.0.401 -t pdb -t portablepdb bin/Release/net10.0/osx-arm64/ -t pdb -t dsym -t elf bin/Release/net10.0/osx-arm64/publish/
.NET 11 RC 2 no upload -t pdb -t dsym -t elf bin/Release/net10.0/osx-arm64/publish/

releases new and set-commits ran in every case.

On the .NET 10 SDK, the native debug files never reach Sentry. Those are the dSYM on macOS, the .dbg file on Linux and the native PDB on Windows. Without them, Sentry can't symbolicate native crashes from these apps. Sentry 6.12.1 from nuget.org shows the same result.

On the .NET 11 SDK, the managed upload doesn't run at all, because that SDK's Native AOT publish skips Build, as described in dotnet/sdk#54515. #5731 hooked CheckSentryCLI and the release targets onto the new publish path, but the managed upload still waits for Build.

Android

For a net10.0-android app with UseMonoRuntime=false and Sentry 6.12.1, dotnet msbuild -t:GetAssemblyAttributes -getItem:AssemblyAttribute lists no io.sentry.ndk.preload metadata. With -p:TargetFramework=net10.0-android, it lists it. The check covers the build output only, not a run on a device.

Why CI doesn't catch it

The integration tests always pass --framework, in integration-test/common.ps1:130 and integration-test/android.Tests.ps1:51.

Workaround

Build and publish with -f <tfm>.

Fix

Also compute the flags near the top of Sentry.targets. NuGet imports that file after the project body, so TargetFramework has its value by then:

<PropertyGroup Condition="'$(TargetFramework)' != ''">
  <_SentryTargetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</_SentryTargetFrameworkVersion>
  <_SentryIsNet8OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 8.0))</_SentryIsNet8OrGreater>
  <_SentryIsNet9OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 9.0))</_SentryIsNet9OrGreater>
  <_SentryIsNet10OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 10.0))</_SentryIsNet10OrGreater>
</PropertyGroup>

Keep the copy in Sentry.props, because the repo's own Directory.Build.props imports it. With this change, the Native AOT case uploads from publish/ on both SDKs and the Android app gets the metadata, all without -f. A cli.Tests.ps1 case that publishes without --framework would keep this covered.

version7 adds _SentryIsNet11OrGreater to Sentry.props and checks it in the Native AOT settings. When this fix reaches version7, the copy in Sentry.targets needs that flag too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

.NETAOTBugMSBuildPlatform: Android

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions