From 9272311f974520af6736c2f60e227706a9d5e3e1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:47:30 -0500 Subject: [PATCH] [release/9.0.1xx-preview7] Remove the 'Resources' prefix from BundleResource (#24024) * Remove the 'Resources' prefix from BundleResource Fixes #23554 Prior to Maui 8.0.70, there was a bug that only removed the "Resources/" prefix, and not the correct "Platforms/iOS/Resource": https://github.com/dotnet/maui/issues/16734 This PR https://github.com/dotnet/maui/pull/23269 fixes the original issue, but now exposed the case where BundleResource were included in the root Resources folder instead of the Platforms/iOS/ folder. * Update Microsoft.Maui.Controls.SingleProject.targets * Update Microsoft.Maui.Controls.SingleProject.targets * Add a test * string --------- Co-authored-by: Matthew Leibowitz --- ...rosoft.Maui.Controls.SingleProject.targets | 18 +++++++++++ .../TemplateTests.cs | 31 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.SingleProject.targets b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.SingleProject.targets index c8183a8997d5..6f4069e6d36d 100644 --- a/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.SingleProject.targets +++ b/src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.SingleProject.targets @@ -61,6 +61,24 @@ + + + + <_MauiOld_ResourcePrefix>$(_ResourcePrefix) + <_ResourcePrefix>Resources;$(_ResourcePrefix) + + + + + <_ResourcePrefix>$(_MauiOld_ResourcePrefix) + + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Maui\Maui.DesignTime.targets diff --git a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs index 178eaa01bdb1..6e50454f3948 100644 --- a/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs +++ b/src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs @@ -342,6 +342,37 @@ public void BuildWindowsRidGraph(string id, bool useridgraph, string packageType $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); } + [Test] + [TestCase("maui", "ios")] + [TestCase("maui", "maccatalyst")] + [TestCase("maui-blazor", "ios")] + [TestCase("maui-blazor", "maccatalyst")] + public void BuildWithCustomBundleResource(string id, string framework) + { + var projectDir = TestDirectory; + var projectFile = Path.Combine(projectDir, $"{Path.GetFileName(projectDir)}.csproj"); + + Assert.IsTrue(DotnetInternal.New(id, projectDir, DotNetCurrent), + $"Unable to create template {id}. Check test output for errors."); + + File.WriteAllText(Path.Combine(projectDir, "Resources", "testfile.txt"), "Something here :)"); + + FileUtilities.ReplaceInFile(projectFile, + "", + $""" + + + + + """); + + var extendedBuildProps = BuildProps; + extendedBuildProps.Add($"TargetFramework={DotNetCurrent}-{framework}"); + + Assert.IsTrue(DotnetInternal.Build(projectFile, "Debug", properties: extendedBuildProps, msbuildWarningsAsErrors: true), + $"Project {Path.GetFileName(projectFile)} failed to build. Check test output/attachments for errors."); + } + [Test] [TestCase("maui", $"{DotNetCurrent}-ios", "ios-arm64")] [TestCase("maui", $"{DotNetCurrent}-ios", "iossimulator-arm64")]