Skip to content

[msbuild] Copy the .dSYM to the publish directory when publishing#26041

Draft
rolfbjarne wants to merge 2 commits into
mainfrom
dev/rolf/issue-15384-copy-the-dsym-to-the-publish-directory-f2e505
Draft

[msbuild] Copy the .dSYM to the publish directory when publishing#26041
rolfbjarne wants to merge 2 commits into
mainfrom
dev/rolf/issue-15384-copy-the-dsym-to-the-publish-directory-f2e505

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

Developers frequently can't find the .dSYM debug symbols after dotnet publish, because they're left in the build output directory (next to the .app) while the published .ipa/.pkg lands in the publish directory. This trips people up when they need to symbolicate crashes or upload symbols to a crash reporting service, and it's a recurring source of confusion in issue #15384.

This change copies any generated *.dSYM directories into the publish directory during dotnet publish, so the debug symbols end up right alongside the published package.

Approach

  • Added a new _CopyDSymToPublishDirectory target in dotnet/targets/Xamarin.Shared.Sdk.Publish.targets, wired into the Publish target via DependsOnTargets (so it runs after the app bundle and its dSYMs already exist).
  • It uses the existing GetDirectories task to find *.dSYM directories next to the app bundle ($(_AppContainerDir)), then copies each one recursively into $(PublishDir), preserving the dSYM folder name and internal structure. SkipUnchangedFiles avoids redundant copies on repeated publishes.
  • A new CopyDSYMToPublishDirectory property controls the behavior. It defaults to true; set it to false to opt out.
  • The target is guarded to macOS host builds (IsOSPlatform('osx')) and to projects that actually produce an app bundle. The Windows remote-build path already retrieves dSYMs separately via CopyDSYMFromMac, so that flow is intentionally untouched.

Notes for reviewers

  • The copy uses item batching on the dSYM directory plus %(RecursiveDir) to reproduce the tree. I could not run the full test suite locally (the environment is missing the required Xcode), so I validated the batching/RecursiveDir destination mapping with a standalone dotnet msbuild repro, and added a PublishDSymToPublishDirectory test (copy on/off) to tests/dotnet/UnitTests/PostBuildTest.cs.
  • Documented the new property in docs/building-apps/build-properties.md.

Fixes: #15384

Fixes #15384

🤖 Pull request created by Copilot

rolfbjarne and others added 2 commits July 10, 2026 14:58
When running `dotnet publish`, the generated `*.dSYM` directories (which are
created next to the app bundle in the output directory) are now copied into the
publish directory, so the debug symbols end up alongside the published
`.ipa`/`.pkg`. This makes it much easier to locate the dSYMs for symbolication
without knowing the exact build output layout.

This can be disabled by setting `CopyDSYMToPublishDirectory=false`.

Fixes #15384

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Avoid a potentially huge string-join in the log message when there are many
files inside the .dSYM directories.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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: 7fc8531578e4e3d29bdc11ac616fc9e498af1638 [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🔥 [CI Build #7fc8531] Test results 🔥

Test results

❌ Tests failed on VSTS: test results

1 tests crashed, 2 tests failed, 196 tests passed.

Failures

❌ dotnettests tests (iOS)

🔥 Failed catastrophically on VSTS: test results - dotnettests_ios (no summary found).

Html Report (VSDrops) Download

❌ dotnettests tests (MacCatalyst)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.PostBuildTest.PublishApplicationArtifactsDependsOn...: '/Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.400-preview.0.26359.109/dotnet' failed with exit code 1
      ...
    • Xamarin.Tests.PostBuildTest.PublishTest(MacCatalyst,"maccatalyst...: 'dotnet publish' failed with exit code 1
      Full command: /Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.40...
    • Xamarin.Tests.PostBuildTest.PublishTest(MacCatalyst,"maccatalyst...: 'dotnet publish' failed with exit code 1
      Full command: /Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.40...

Html Report (VSDrops) Download

❌ dotnettests tests (macOS)

1 tests failed, 0 tests passed.

Failed tests

  • DotNet tests: Failed (Execution failed with exit code 1)
    • Xamarin.Tests.PostBuildTest.PublishTest(MacOSX,"osx-arm64;osx-x6...: 'dotnet publish' failed with exit code 1
      Full command: /Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.40...
    • Xamarin.Tests.PostBuildTest.PublishTest(MacOSX,"osx-x64"): 'dotnet publish' failed with exit code 1
      Full command: /Users/cloudtest/vss/_work/1/s/macios/builds/downloads/dotnet-sdk-10.0.40...

Html Report (VSDrops) Download

Successes

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: 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. 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: 7fc8531578e4e3d29bdc11ac616fc9e498af1638 [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.

Copy the .dSYM to the publish directory

2 participants