From 61c41837a8dc9b2bb766e4ecb282c51b5850ac24 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 1 Apr 2026 11:19:00 +0200 Subject: [PATCH] [msbuild] Fix Content/BundleResource with PublishFolderType not bundled in multi-RID builds. Fixes #25053. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In multi-RID (universal) builds, the outer build saves all Content and BundleResource items to processed-items files, and inner builds remove them. However, items with PublishFolderType are not actually processed by CollectBundleResources (it skips them) — they're handled via ResolvedFileToPublish instead. By incorrectly saving them as processed, the inner builds remove them before they can be added to ResolvedFileToPublish, so they never end up in the app bundle. Fix by filtering out items with PublishFolderType when writing the processed-items files. Fixes https://github.com/dotnet/macios/issues/25053. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- msbuild/Xamarin.Shared/Xamarin.Shared.targets | 13 ++++++++++--- tests/dotnet/BundleStructure/BundleResourceJ.txt | 1 + tests/dotnet/BundleStructure/ContentJ.txt | 1 + tests/dotnet/BundleStructure/shared.csproj | 8 ++++++++ tests/dotnet/UnitTests/BundleStructureTest.cs | 2 ++ 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 tests/dotnet/BundleStructure/BundleResourceJ.txt create mode 100644 tests/dotnet/BundleStructure/ContentJ.txt diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index a0cd06a1fa02..6531ef783efa 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -472,9 +472,16 @@ Copyright (C) 2018 Microsoft. All rights reserved. - - - + + + <_BundleResourceToSave Include="@(BundleResource)" Condition="'%(BundleResource.PublishFolderType)' == ''" /> + <_ContentToSave Include="@(Content)" Condition="'%(Content.PublishFolderType)' == ''" /> + + + diff --git a/tests/dotnet/BundleStructure/BundleResourceJ.txt b/tests/dotnet/BundleStructure/BundleResourceJ.txt new file mode 100644 index 000000000000..7eb01fc1b740 --- /dev/null +++ b/tests/dotnet/BundleStructure/BundleResourceJ.txt @@ -0,0 +1 @@ +BundleResourceJ diff --git a/tests/dotnet/BundleStructure/ContentJ.txt b/tests/dotnet/BundleStructure/ContentJ.txt new file mode 100644 index 000000000000..77e00d8e75d4 --- /dev/null +++ b/tests/dotnet/BundleStructure/ContentJ.txt @@ -0,0 +1 @@ +ContentJ diff --git a/tests/dotnet/BundleStructure/shared.csproj b/tests/dotnet/BundleStructure/shared.csproj index 6fd02566537e..2f8ad66ed705 100644 --- a/tests/dotnet/BundleStructure/shared.csproj +++ b/tests/dotnet/BundleStructure/shared.csproj @@ -218,6 +218,10 @@ None + + + Resource + @@ -288,6 +292,10 @@ None + + + Resource + diff --git a/tests/dotnet/UnitTests/BundleStructureTest.cs b/tests/dotnet/UnitTests/BundleStructureTest.cs index 035e665fd8d6..13b5f6ca256a 100644 --- a/tests/dotnet/UnitTests/BundleStructureTest.cs +++ b/tests/dotnet/UnitTests/BundleStructureTest.cs @@ -257,6 +257,7 @@ internal static void CheckAppBundleContents (ApplePlatform platform, IEnumerable expectedFiles.Add (Path.Combine (resourcesDirectory, "ContentD.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "ContentE.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "ContentI.txt")); + expectedFiles.Add (Path.Combine (resourcesDirectory, "ContentJ.txt")); // expectedFiles.Add (Path.Combine (resourcesDirectory, "EmbeddedResourceA.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "EmbeddedResourceB.txt")); @@ -270,6 +271,7 @@ internal static void CheckAppBundleContents (ApplePlatform platform, IEnumerable expectedFiles.Add (Path.Combine (resourcesDirectory, "BundleResourceD.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "BundleResourceE.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "BundleResourceI.txt")); + expectedFiles.Add (Path.Combine (resourcesDirectory, "BundleResourceJ.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "AutoIncluded.txt")); expectedFiles.Add (Path.Combine (resourcesDirectory, "SubDirectory"));