Skip to content

[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494

Open
rolfbjarne wants to merge 5 commits into
mainfrom
dev/rolf/issue-25491-strip-exported-symbols
Open

[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494
rolfbjarne wants to merge 5 commits into
mainfrom
dev/rolf/issue-25491-strip-exported-symbols

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

When _ExportSymbolsExplicitly=false, the strip command was running without any flags on the main executable, stripping all symbols including ones the runtime needs, causing the app to crash at launch.

Changes

  1. msbuild/Xamarin.Shared/Xamarin.Shared.targets — Always pass the symbol file to strip (revert the condition from PR [msbuild] Don't pass symbol file to strip when _ExportSymbolsExplicitly=false. Fixes #24582. #24800 that removed it when _ExportSymbolsExplicitly=false).

  2. msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs — Implement GetAdditionalItemsToBeCopied() to ensure the symbol file is transferred to the remote Mac for Windows→Mac builds, so remote builds behave identically to local builds.

  3. tests/dotnet/UnitTests/ProjectTest.cs — Add StrippedWithExportSymbolsExplicitlyFalse test that builds with _ExportSymbolsExplicitly=false, executes the app, and verifies required symbols remain in the binary.

Root cause

PR #24800 fixed a build failure for remote Windows builds by removing the symbol file from the strip command when _ExportSymbolsExplicitly=false. However, running bare strip (without -i -s <symbolfile>) removes all symbols from the main executable, including ones the .NET runtime needs at launch.

Fix approach

Instead of conditionally omitting the symbol file, we now:

  • Always pass the symbol file to strip (it's always written unconditionally by WriteLinesToFile)
  • Ensure it gets transferred to the remote Mac via GetAdditionalItemsToBeCopied()

This ensures consistent behavior between local and remote builds.

Fixes #25491

🤖 Pull request created by Copilot

rolfbjarne and others added 2 commits May 21, 2026 19:30
…Fixes #25491.

When _ExportSymbolsExplicitly=false, the strip command was running without
any flags on the main executable, which strips all symbols including ones
the runtime needs, causing the app to crash at launch.

Fix by:
1. Always passing the symbol file to strip (reverting the condition from
   PR #24800).
2. Making the SymbolStrip task resilient: if the symbol file doesn't exist
   (e.g. Windows remote builds), fall back to '-S -x' (strip debug and
   local symbols only) instead of bare 'strip'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Instead of falling back to different strip behavior when the symbol file
is missing, ensure the file is always transferred to the remote Mac by
implementing GetAdditionalItemsToBeCopied in the SymbolStrip task.

This ensures remote builds behave identically to local builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

The GetAdditionalItemsToBeCopied() method needs the local (Windows) path
to know which file to copy to the remote Mac build server. Added a
SymbolFileLocalPath property that holds the local path while SymbolFile
retains the Mac-resolved path for the actual strip command.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@rolfbjarne rolfbjarne marked this pull request as ready for review June 25, 2026 10:47
@rolfbjarne rolfbjarne requested a review from mauroa as a code owner June 25, 2026 10:47
Copilot AI review requested due to automatic review settings June 25, 2026 10:47

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

Fixes a launch-time crash caused by invoking strip without arguments when _ExportSymbolsExplicitly=false, by ensuring the exported-symbol list is still used during symbol stripping (and is available in remote builds).

Changes:

  • Always provide the symbols list file to the post-processing strip step (regardless of _ExportSymbolsExplicitly).
  • Extend the SymbolStrip MSBuild task to include the symbols list among files copied to the remote Mac (Windows→Mac builds).
  • Add a unit test validating that required runtime symbols remain after stripping with _ExportSymbolsExplicitly=false.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
msbuild/Xamarin.Shared/Xamarin.Shared.targets Always supplies the symbol list to SymbolStrip and threads through a local-path metadata for remote copy support.
msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs Adds SymbolFileLocalPath and begins implementing remote-copy support via GetAdditionalItemsToBeCopied().
tests/dotnet/UnitTests/ProjectTest.cs Adds a regression test for stripping with _ExportSymbolsExplicitly=false.

Comment thread msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs
Comment thread tests/dotnet/UnitTests/ProjectTest.cs
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #9170dd6] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 9170dd6037b287df3da1658030e7e148d9d39364 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #9170dd6] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 9170dd6037b287df3da1658030e7e148d9d39364 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 9170dd6037b287df3da1658030e7e148d9d39364 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ [PR Build #9170dd6] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 9170dd6037b287df3da1658030e7e148d9d39364 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #9170dd6] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 199 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 17 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 18 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 9170dd6037b287df3da1658030e7e148d9d39364 [PR build]

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean .NET MAUI iOS app crashes on launch when _ExportSymbolsExplicitly=false

4 participants