Skip to content

[msbuid] Fix Content items with PublishFolderType losing files that match SDK names. Fixes #25497.#25528

Open
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/issue-25497-content-publishfoldertype
Open

[msbuid] Fix Content items with PublishFolderType losing files that match SDK names. Fixes #25497.#25528
rolfbjarne wants to merge 1 commit into
mainfrom
dev/rolf/issue-25497-content-publishfoldertype

Conversation

@rolfbjarne
Copy link
Copy Markdown
Member

Content items with PublishFolderType (e.g. RootDirectory) would lose files
whose names match SDK assemblies or runtime files (e.g. libclrgc.dylib,
Microsoft.macOS.dll). This happened because the .NET SDK's
ResolveOverlappingItemGroupConflicts task (during ComputeResolvedFilesToPublishList)
removes user items when their filename conflicts with SDK package files.

Fix this by setting TargetPath metadata (from Link) when Content/BundleResource
items with PublishFolderType are first added to ResolvedFileToPublish. This way
the conflict resolver sees the full relative path (e.g.
Contents/SharedSupport/SubApp.app/.../libclrgc.dylib) instead of just the
filename, and doesn't flag them as conflicts with SDK files.

Fixes #25497.

…atch SDK names. Fixes #25497.

Content items with PublishFolderType (e.g. RootDirectory) would lose files
whose names match SDK assemblies or runtime files (e.g. libclrgc.dylib,
Microsoft.macOS.dll). This happened because the .NET SDK's
ResolveOverlappingItemGroupConflicts task (during ComputeResolvedFilesToPublishList)
removes user items when their filename conflicts with SDK package files.

Fix this by setting TargetPath metadata (from Link) when Content/BundleResource
items with PublishFolderType are first added to ResolvedFileToPublish. This way
the conflict resolver sees the full relative path (e.g.
Contents/SharedSupport/SubApp.app/.../libclrgc.dylib) instead of just the
filename, and doesn't flag them as conflicts with SDK files.

Fixes #25497.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 26, 2026 18:19
@rolfbjarne rolfbjarne requested a review from mauroa as a code owner May 26, 2026 18:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an Apple workload/MSBuild publish issue where Content/BundleResource items with PublishFolderType could be dropped when their filenames overlap with SDK/runtime files, by ensuring those items carry a path-aware TargetPath (derived from Link) early enough for the .NET SDK conflict resolver to treat them as distinct.

Changes:

  • Set ResolvedFileToPublish.TargetPath from Link for Content/BundleResource items that specify PublishFolderType.
  • Add a new macOS test project that publishes a nested helper .app bundle via Content + PublishFolderType=RootDirectory.
  • Add a unit test (and helper bundle payload) validating files with SDK-like names (e.g. Microsoft.macOS.dll, libclrgc.dylib) are preserved.

Reviewed changes

Copilot reviewed 5 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
msbuild/Xamarin.Shared/Xamarin.Shared.targets Ensures ResolvedFileToPublish items with PublishFolderType get TargetPath from Link to avoid filename-only conflict resolution.
tests/dotnet/UnitTests/ContentWithPublishFolderTypeTest.cs Regression test asserting SDK-like filenames are still copied into the app bundle when published via Content + PublishFolderType.
tests/dotnet/ContentWithPublishFolderType/macOS/ContentWithPublishFolderType.csproj New macOS test project that publishes helper/**/* into Contents/SharedSupport/... using Link.
tests/dotnet/ContentWithPublishFolderType/AppDelegate.cs Minimal entry point for the new test project.
tests/dotnet/ContentWithPublishFolderType/helper/.gitignore Local ignore override to allow committing test .dll payloads under helper/.
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/System.ServiceModel.Security.dll Test payload file for publish verification.
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/libclrgc.dylib Test payload file for publish verification (runtime-like name).
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/HeartbeatHandlerLib.dll Test payload file for publish verification.
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/AsyncIO.dll Test payload file for publish verification.
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.VisualBasic.dll Test payload file for publish verification (SDK-like name).
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.macOS.dll Test payload file for publish verification (SDK-like name).
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/.xamarin/osx-arm64/Microsoft.CSharp.dll Test payload file for publish verification (SDK-like name).
tests/dotnet/ContentWithPublishFolderType/helper/SubApp.app/Contents/MonoBundle/.xamarin/osx-arm64/HeartBeatHandlerMac.dll Test payload file for publish verification.

</ItemGroup>

<ItemGroup>
<Content Include="../helper/**/*">
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #0b43e8f] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: 0b43e8f533c71f5086be45eecf3aaace14561a77 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

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

✅ [PR Build #0b43e8f] Build passed (Build packages) ✅

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

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

✅ [PR Build #0b43e8f] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: 0b43e8f533c71f5086be45eecf3aaace14561a77 [PR build]

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

🚀 [CI Build #0b43e8f] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 193 tests passed 🎉

Tests counts

✅ 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 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 20 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 23 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 23 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): 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: 0b43e8f533c71f5086be45eecf3aaace14561a77 [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.

Content + PublishFolderType ignores some files (.dylib, .dll) during copy

5 participants