Skip to content

build: fix intermittent Sentry.aar file lock when packing Android projects - #5593

Open
jamescrosswell wants to merge 2 commits into
mainfrom
fix/pack-sentry-aar-lock
Open

jamescrosswell wants to merge 2 commits into
mainfrom
fix/pack-sentry-aar-lock

Conversation

@jamescrosswell

Copy link
Copy Markdown
Collaborator

The .NET (linux-x64) job intermittently fails at Create NuGet Packages with XARLP7024 ... Sentry.aar because it is being used by another process (e.g. runs 33028776243, 33814442277, 34296591536, 35170680025 twice).

Closes #5092

Root cause

The .aar that locks isn't produced by the build. It's written during dotnet pack --no-build:

  • Pack's per-TFM walk calls _GetFrameworkAssemblyReferences, which depends on ResolveReferences. On Android that pulls in _UpdateAndroidResources_CreateAar.
  • In a normal build, _CreateAar runs early, before the bindings' native libraries (libsentry.so etc.) are extracted into EmbeddedNativeLibrary. It is skipped with "no inputs", so no Sentry.aar exists after the build.
  • In a no-build pack those items are already populated when _CreateAar runs, so it writes src/Sentry/bin/Release/net10.0-android36.0/Sentry.aar (and Sentry.Maui.aar) mid-pack.
  • Meanwhile Sentry.Maui's pack, running in parallel, globs *.aar from its reference directories (_ResolveAars) and hashes them in ResolveLibraryProjectImports. On Linux, .NET emulates FileShare with flock, so the writer's exclusive lock makes that read fail.

Verified locally with binlogs: after a Release build no Sentry.aar/Sentry.Maui.aar exists, and dotnet pack --no-build creates both.

Fix

In src/Directory.Build.targets, for Android TFMs under NoBuild, clear _CreateAarInputs just before _CreateAar. It is then skipped exactly as in the build. No workflow change needed.

  • Package contents are unchanged: the file lists of Sentry.Bindings.Android, Sentry and Sentry.Maui nupkgs are identical with and without the change. The project .aar is created after pack has already collected content, so a fresh pack never included it.
  • Sentry.Bindings.Android.aar (a genuine build output) is left untouched.
  • Side benefit: without the fix, packing twice locally embeds the stale ~1.2 MB Sentry.aar (a duplicate of the bindings' native libs) in Sentry.nupkg.

This hooks the Android SDK's private _CreateAar/_CreateAarInputs names. If a future SDK renames them, the target becomes a silent no-op rather than a build break.

#skip-changelog

🤖 Generated with Claude Code

…jects race on

With --no-build, pack reaches _CreateAar through ResolveReferences after the
native library inputs have been extracted, so it writes <Project>.aar mid-pack.
Dependent Android projects packed in parallel hash that file in
ResolveLibraryProjectImports and fail with XARLP7024 on Linux.

Closes #5092

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.84%. Comparing base (cba98c9) to head (cd26cde).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5593      +/-   ##
==========================================
+ Coverage   74.76%   74.84%   +0.08%     
==========================================
  Files         515      515              
  Lines       18963    18963              
  Branches     3694     3694              
==========================================
+ Hits        14177    14193      +16     
+ Misses       3908     3892      -16     
  Partials      878      878              

☔ 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.

@jamescrosswell
jamescrosswell marked this pull request as ready for review September 17, 2026 23:25
@github-actions github-actions Bot added the risk: low PR risk score: low label Sep 17, 2026

@ric-oliv ric-oliv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! Just left one comment, but not blocking.

Comment thread src/Directory.Build.targets Outdated
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI frequently fails for Linux because Sentry.aar is being used by another process

2 participants