Skip to content

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

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

[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494
rolfbjarne wants to merge 3 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
Copy link
Copy Markdown
Collaborator

✅ [PR Build #6e79bbc] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 6e79bbc41e0685c8678f296b50eeed072654d651 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #6e79bbc] Build passed (Build packages) ✅

Pipeline on Agent
Hash: 6e79bbc41e0685c8678f296b50eeed072654d651 [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: 6e79bbc41e0685c8678f296b50eeed072654d651 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #6e79bbc] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 6e79bbc41e0685c8678f296b50eeed072654d651 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🔥 [CI Build #6e79bbc] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

0 tests crashed, 3 tests failed, 180 tests passed.

Failures

❌ fsharp tests

2 tests failed, 2 tests passed.

Failed tests

  • fsharp/iOS - simulator/Debug: LaunchTimedOut
  • fsharp/tvOS - simulator/Debug: LaunchTimedOut

Html Report (VSDrops) Download

❌ monotouch tests (tvOS)

1 tests failed, 17 tests passed.

Failed tests

  • monotouch-test/tvOS - simulator/Release (trimmable static registrar, NativeAOT, x64): TimedOut

Html Report (VSDrops) Download

Successes

✅ 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 Publish failed ⚠️) Download
✅ dotnettests (tvOS): All 1 tests passed. (⚠️ Html Report Publish failed ⚠️) Download
✅ framework: All 2 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 6 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 11 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 20 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: 6e79bbc41e0685c8678f296b50eeed072654d651 [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

2 participants