[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494
[msbuild] Fix app crash at launch when _ExportSymbolsExplicitly=false. Fixes #25491#25494rolfbjarne wants to merge 3 commits into
Conversation
…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>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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>
✅ [PR Build #6e79bbc] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #6e79bbc] Build passed (Build packages) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [PR Build #6e79bbc] Build passed (Build macOS tests) ✅Pipeline on Agent |
🔥 [CI Build #6e79bbc] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 3 tests failed, 180 tests passed. Failures❌ fsharp tests2 tests failed, 2 tests passed.Failed tests
Html Report (VSDrops) Download ❌ monotouch tests (tvOS)1 tests failed, 17 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
When
_ExportSymbolsExplicitly=false, thestripcommand 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
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).msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs— ImplementGetAdditionalItemsToBeCopied()to ensure the symbol file is transferred to the remote Mac for Windows→Mac builds, so remote builds behave identically to local builds.tests/dotnet/UnitTests/ProjectTest.cs— AddStrippedWithExportSymbolsExplicitlyFalsetest 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
stripcommand when_ExportSymbolsExplicitly=false. However, running barestrip(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:
WriteLinesToFile)GetAdditionalItemsToBeCopied()This ensures consistent behavior between local and remote builds.
Fixes #25491
🤖 Pull request created by Copilot