Skip to content

Commit

Permalink
Try a different approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Jan 16, 2025
1 parent 02f3c64 commit 78dc570
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
7 changes: 7 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/PackLibraryResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ public override bool Execute ()
{
var results = new List<ITaskItem> ();

var hashOriginalResources = new HashSet<string> (BundleOriginalResourcesWithLogicalNames.Select (v => v.ItemSpec));

foreach (var item in BundleResourcesWithLogicalNames) {
if (hashOriginalResources.Contains (item.ItemSpec)) {
Log.LogMessage (MessageImportance.Low, $"Skipping BundleResourcesWithLogicalNames={item.ItemSpec}, because it's also specified in BundleOriginalResourcesWithLogicalNames");
continue;
}

var logicalName = item.GetMetadata ("LogicalName");

if (string.IsNullOrEmpty (logicalName)) {
Expand Down
5 changes: 0 additions & 5 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,6 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<Output TaskParameter="ItemsWithLogicalNames" ItemName="_BundleOriginalResourceWithLogicalName" />

</CollectPackLibraryResources>

<!-- make sure we don't bundle the same resource more than once -->
<ItemGroup>
<_BundleResourceWithLogicalName Remove="@(_BundleOriginalResourceWithLogicalName)" />
</ItemGroup>
</Target>

<!--
Expand Down
13 changes: 9 additions & 4 deletions tests/BundledResources/ResourcesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

using System;
using System.IO;
using System.Linq;
using NUnit.Framework;

using Foundation;
Expand Down Expand Up @@ -41,10 +42,14 @@ public void Bundled ()
if (!hasResources) {
Assert.That (resources.Length, Is.EqualTo (0), "No resources");
} else {
Assert.That (resources.Length, Is.GreaterThanOrEqualTo (2), "Resources");
Assert.That (resources, Contains.Item ("__monotouch_content_basn3p08.png"), "res-basn3p08.png");
Assert.That (resources, Contains.Item ("__monotouch_content_basn3p08__with__loc.png"), "res-basn3p08_with_loc.png");
Assert.That (resources, Contains.Item ("__monotouch_content_xamvideotest.mp4"), "res-xamvideotest.mp4");
var expectedResources = new string [] {
"basn3p08.png",
"basn3p08__with__loc.png",
"xamvideotest.mp4",
};
var oldPrefixed = expectedResources.Select (v => $"__monotouch_content_{v}").ToArray ();
var newPrefixed = expectedResources.Select (v => $"__monotouch_item_BundleResource_{v}").ToArray ();
Assert.That (resources, Is.EquivalentTo (oldPrefixed).Or.EquivalentTo (newPrefixed), "Resources");
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,6 @@ public void LibraryWithResources (ApplePlatform platform, bool? bundleOriginalRe
var platformPrefix = (platform == ApplePlatform.MacOSX) ? "xammac" : "monotouch";
if (actualBundleOriginalResources) {
expectedResources = new string [] {
$"__{platformPrefix}_content_A.ttc",
$"__{platformPrefix}_content_B.otf",
$"__{platformPrefix}_content_C.ttf",
$"__{platformPrefix}_item_AtlasTexture_Archer__Attack.atlas_sarcher__attack__0001.png",
$"__{platformPrefix}_item_AtlasTexture_Archer__Attack.atlas_sarcher__attack__0002.png",
$"__{platformPrefix}_item_AtlasTexture_Archer__Attack.atlas_sarcher__attack__0003.png",
Expand Down

0 comments on commit 78dc570

Please sign in to comment.