[msbuid] Fix Content items with PublishFolderType losing files that match SDK names. Fixes #25497.#25528
[msbuid] Fix Content items with PublishFolderType losing files that match SDK names. Fixes #25497.#25528rolfbjarne wants to merge 1 commit into
Conversation
…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>
There was a problem hiding this comment.
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.TargetPathfromLinkforContent/BundleResourceitems that specifyPublishFolderType. - Add a new macOS test project that publishes a nested helper
.appbundle viaContent+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/**/*"> |
✅ [PR Build #0b43e8f] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #0b43e8f] 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 #0b43e8f] Build passed (Build macOS tests) ✅Pipeline on Agent |
🚀 [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 macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
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.