Skip to content

Commit

Permalink
[release/8.0.1xx-sr7] Remove the 'Resources' prefix from BundleResour…
Browse files Browse the repository at this point in the history
…ce (#24015)

* 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": #16734

This PR #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

* Update Versions.props

* Add a test

# Conflicts:
#	src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs

* string

---------

Co-authored-by: Matthew Leibowitz <[email protected]>
Co-authored-by: Shane Neuville <[email protected]>
  • Loading branch information
3 people authored Aug 5, 2024
1 parent 911f058 commit f4879b8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<PropertyGroup>
<!-- The .NET product branding version -->
<ProductVersion>8.0.71</ProductVersion>
<ProductVersion>8.0.72</ProductVersion>
<MajorVersion>8</MajorVersion>
<MinorVersion>0</MinorVersion>
<PatchVersion>71</PatchVersion>
<PatchVersion>72</PatchVersion>
<SdkBandVersion>8.0.100</SdkBandVersion>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<!-- Servicing builds have different characteristics for the way dependencies, baselines, and versions are handled. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@

</Target>

<!--
TEMPORARY workaround for the issue where the resource starts with the Resources/ prefix,
either in the Identity or Link metadata. The fix is to assume that was not intended
since that is how it worked in 8.0.60 and earlier.
See: https://github.com/xamarin/xamarin-macios/issues/20968
-->
<Target Name="_MauiBefore_CollectBundleResources" BeforeTargets="_CollectBundleResources">
<PropertyGroup>
<_MauiOld_ResourcePrefix>$(_ResourcePrefix)</_MauiOld_ResourcePrefix>
<_ResourcePrefix>Resources;$(_ResourcePrefix)</_ResourcePrefix>
</PropertyGroup>
</Target>
<Target Name="_MauiAfter_CollectBundleResources" AfterTargets="_CollectBundleResources">
<PropertyGroup>
<_ResourcePrefix>$(_MauiOld_ResourcePrefix)</_ResourcePrefix>
</PropertyGroup>
</Target>

<!-- Import Maui Single Project property pages -->
<PropertyGroup Condition="'$(MauiDesignTimeTargetsPath)' == ''">
<MauiDesignTimeTargetsPath>$(MSBuildExtensionsPath)\Microsoft\VisualStudio\Maui\Maui.DesignTime.targets</MauiDesignTimeTargetsPath>
Expand Down
31 changes: 31 additions & 0 deletions src/TestUtils/src/Microsoft.Maui.IntegrationTests/TemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,37 @@ public void BuildWindowsAppSDKSelfContained(string id, bool wasdkself, bool nets
$"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,
"</Project>",
$"""
<ItemGroup>
<BundleResource Include="Resources\testfile.txt" />
</ItemGroup>
</Project>
""");

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")]
public void PublishNativeAOT(string id, string framework, string runtimeIdentifier)
Expand Down

0 comments on commit f4879b8

Please sign in to comment.