Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0.1xx-preview7] Remove the 'Resources' prefix from BundleResource #24024

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
"</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")]
[TestCase("maui", $"{DotNetCurrent}-ios", "iossimulator-arm64")]
Expand Down