From d6deb4bbe45351c85fc52d0ab8c38ce689019290 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 11 Aug 2023 15:47:35 -0300 Subject: [PATCH 01/18] feat: added property to know the TargetFramework --- src/.nuspec/Uno.Resizetizer.targets | 3 ++- src/Resizetizer/src/ResizetizeImages.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/.nuspec/Uno.Resizetizer.targets b/src/.nuspec/Uno.Resizetizer.targets index 721596041f7e..fdfe9669971e 100644 --- a/src/.nuspec/Uno.Resizetizer.targets +++ b/src/.nuspec/Uno.Resizetizer.targets @@ -317,7 +317,7 @@ - + @@ -423,6 +423,7 @@ IntermediateOutputIconPath="$(_UnoIntermediateAppIcon)" PWAManifestPath="$(_WasmPwaManifestPath)" InputsFile="$(_UnoResizetizerInputsFile);$(_UnoSplashInputsFile)" + TargetFramework="$(_UnoResizetizerPlatformIdentifier)" Images="@(UnoImage->Distinct())"> Date: Fri, 11 Aug 2023 16:07:26 -0300 Subject: [PATCH 02/18] feat: added a new property on UnoIcon --- .../NewTemplate/Resizetizer.Extensions.Sample.Base/base.props | 3 ++- src/.nuspec/Uno.Resizetizer.targets | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props b/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props index 979f0902b515..a8a35e61472d 100644 --- a/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props +++ b/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props @@ -13,7 +13,8 @@ + Color="#00000000" + ProjectDirectory="$(MSBuildThisFileDirectory)"/> - + From f15f3100ce0bb6fe10c2fab3d34a00a04ccde2a5 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 11 Aug 2023 16:17:38 -0300 Subject: [PATCH 03/18] feat: app icon on windows are generated in the correct folder --- src/Resizetizer/src/DpiPath.cs | 2 +- src/Resizetizer/src/ResizeImageInfo.cs | 29 +++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Resizetizer/src/DpiPath.cs b/src/Resizetizer/src/DpiPath.cs index 5e61872de4a3..5e6b89b82e2c 100644 --- a/src/Resizetizer/src/DpiPath.cs +++ b/src/Resizetizer/src/DpiPath.cs @@ -95,7 +95,7 @@ public static DpiPath[] AppIcon public static class Windows { public const string OutputPath = ""; - public const string IconOutputPath = "Images/"; + public const string IconOutputPath = ""; //"Images/"; public static DpiPath Original => new DpiPath(OutputPath, 1.0m, null, ".scale-100"); diff --git a/src/Resizetizer/src/ResizeImageInfo.cs b/src/Resizetizer/src/ResizeImageInfo.cs index 04d03a376462..62e65d13c0f7 100644 --- a/src/Resizetizer/src/ResizeImageInfo.cs +++ b/src/Resizetizer/src/ResizeImageInfo.cs @@ -83,17 +83,40 @@ public static List Parse(IEnumerable? images) throw new FileNotFoundException("Unable to find background file: " + fileInfo.FullName, fileInfo.FullName); } + if (bool.TryParse(image.GetMetadata(nameof(IsAppIcon)), out var iai)) + { + info.IsAppIcon = iai; + } + info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); if (string.IsNullOrWhiteSpace(info.Alias)) { - var projDirectory = image.GetMetadata("DefiningProjectDirectory"); + var windowsAndAppIcon = ResizetizeImages_v0._TargetFramework == "windows" && info.IsAppIcon; + + if (!windowsAndAppIcon) + { + var projDirectory = image.GetMetadata("DefiningProjectDirectory"); - if (!string.IsNullOrWhiteSpace(projDirectory)) + if (!string.IsNullOrWhiteSpace(projDirectory)) + { + info.Alias = fileInfo.FullName.Replace(projDirectory, string.Empty); + } + } + else { - info.Alias = fileInfo.FullName.Replace(projDirectory, string.Empty); + +#if DEBUG_RESIZETIZER + System.Diagnostics.Debugger.Launch(); +#endif + var projDirectory = image.GetMetadata("ProjectDirectory"); + + if (!string.IsNullOrWhiteSpace(projDirectory)) + { + info.Alias = fileInfo.FullName.Replace(projDirectory, string.Empty); + } } } From 787bc4764711871542dc00095f125a852851c078 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 11 Aug 2023 16:47:24 -0300 Subject: [PATCH 04/18] chore: changed the TFM order on mobile project --- .../Resizetizer.Extensions.Sample.Mobile.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/NewTemplate/Resizetizer.Extensions.Sample.Mobile/Resizetizer.Extensions.Sample.Mobile.csproj b/samples/NewTemplate/Resizetizer.Extensions.Sample.Mobile/Resizetizer.Extensions.Sample.Mobile.csproj index 8c5db0ae2dfb..db2846de5589 100644 --- a/samples/NewTemplate/Resizetizer.Extensions.Sample.Mobile/Resizetizer.Extensions.Sample.Mobile.csproj +++ b/samples/NewTemplate/Resizetizer.Extensions.Sample.Mobile/Resizetizer.Extensions.Sample.Mobile.csproj @@ -1,6 +1,6 @@ - net7.0-ios;net7.0-android;net7.0-maccatalyst + net7.0-android;net7.0-ios;net7.0-maccatalyst true Exe From 96b4570ee3206c62b37cc867101a95721cd970cf Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 11 Aug 2023 18:03:11 -0300 Subject: [PATCH 05/18] fix: adjusted appicons path on manifest file --- src/Resizetizer/src/GeneratePackageAppxManifest.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Resizetizer/src/GeneratePackageAppxManifest.cs b/src/Resizetizer/src/GeneratePackageAppxManifest.cs index 0bcd0ad2514d..3f4a8163caf7 100644 --- a/src/Resizetizer/src/GeneratePackageAppxManifest.cs +++ b/src/Resizetizer/src/GeneratePackageAppxManifest.cs @@ -159,7 +159,7 @@ void UpdateManifest(XDocument appx) if (xelem == null || string.IsNullOrEmpty(xelem.Value) || xelem.Value == PngPlaceholder) { var dpi = DpiPath.Windows.StoreLogo[0]; - var path = Path.Combine(dpi.Path, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); + var path = Path.Combine(dpi.Path + appIconInfo.OutputPath, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); properties.SetElementValue(xname, path); } } @@ -252,7 +252,7 @@ void UpdateManifest(XDocument appx) if (attr == null || string.IsNullOrEmpty(attr.Value) || attr.Value == PngPlaceholder) { var dpi = DpiPath.Windows.MediumTile[0]; - var path = Path.Combine(dpi.Path, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); + var path = Path.Combine(dpi.Path + appIconInfo.OutputPath, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); visual.SetAttributeValue(xname, path); } } @@ -264,7 +264,7 @@ void UpdateManifest(XDocument appx) if (attr == null || string.IsNullOrEmpty(attr.Value) || attr.Value == PngPlaceholder) { var dpi = DpiPath.Windows.Logo[0]; - var path = Path.Combine(dpi.Path, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); + var path = Path.Combine(dpi.Path + appIconInfo.OutputPath, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); visual.SetAttributeValue(xname, path); } } @@ -288,7 +288,7 @@ void UpdateManifest(XDocument appx) if (attr == null || string.IsNullOrEmpty(attr.Value) || attr.Value == PngPlaceholder) { var dpi = DpiPath.Windows.WideTile[0]; - var path = Path.Combine(dpi.Path, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); + var path = Path.Combine(dpi.Path + appIconInfo.OutputPath, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); tile.SetAttributeValue(xname, path); } } @@ -300,7 +300,7 @@ void UpdateManifest(XDocument appx) if (attr == null || string.IsNullOrEmpty(attr.Value) || attr.Value == PngPlaceholder) { var dpi = DpiPath.Windows.SmallTile[0]; - var path = Path.Combine(dpi.Path, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); + var path = Path.Combine(dpi.Path + appIconInfo.OutputPath, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); tile.SetAttributeValue(xname, path); } } @@ -312,7 +312,7 @@ void UpdateManifest(XDocument appx) if (attr == null || string.IsNullOrEmpty(attr.Value) || attr.Value == PngPlaceholder) { var dpi = DpiPath.Windows.LargeTile[0]; - var path = Path.Combine(dpi.Path, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); + var path = Path.Combine(dpi.Path + appIconInfo.OutputPath, appIconInfo.OutputName + dpi.NameSuffix + imageExtension); tile.SetAttributeValue(xname, path); } } From 82d8a4826d440a7a9d614152dfb1bfc942996667 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 11 Aug 2023 18:10:51 -0300 Subject: [PATCH 06/18] chore: code clean up --- src/Resizetizer/src/DpiPath.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resizetizer/src/DpiPath.cs b/src/Resizetizer/src/DpiPath.cs index 5e6b89b82e2c..2c6f10286efa 100644 --- a/src/Resizetizer/src/DpiPath.cs +++ b/src/Resizetizer/src/DpiPath.cs @@ -95,7 +95,7 @@ public static DpiPath[] AppIcon public static class Windows { public const string OutputPath = ""; - public const string IconOutputPath = ""; //"Images/"; + public const string IconOutputPath = ""; public static DpiPath Original => new DpiPath(OutputPath, 1.0m, null, ".scale-100"); From 774892b0ae98529aa2afb88dc6bb1802aad527eb Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 11 Aug 2023 18:11:09 -0300 Subject: [PATCH 07/18] fix: fixed targets tests --- .../Resizetizer.Extensions.Sample.Skia.WPF.csproj | 2 +- .../Resizetizer.Extensions.Sample.Windows.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj b/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj index 3be5d8ff1549..d94bd504ce5f 100644 --- a/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj +++ b/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj @@ -43,7 +43,7 @@ <_ResizetizerSplashScreenPath>$(_UnoIntermediateImages)splash_screen.scale-125.png <_ResizetizerAppIconPath>$(_UnoIntermediateImages)iconapp.ico - <_ResizetizerAppIconImagesPath>$(_UnoIntermediateImages)iconapp.png + <_ResizetizerAppIconImagesPath>$(_UnoIntermediateImages)\Icons\iconapp.png diff --git a/samples/NewTemplate/Resizetizer.Extensions.Sample.Windows/Resizetizer.Extensions.Sample.Windows.csproj b/samples/NewTemplate/Resizetizer.Extensions.Sample.Windows/Resizetizer.Extensions.Sample.Windows.csproj index b260d54ba1a8..04061a70a3f0 100644 --- a/samples/NewTemplate/Resizetizer.Extensions.Sample.Windows/Resizetizer.Extensions.Sample.Windows.csproj +++ b/samples/NewTemplate/Resizetizer.Extensions.Sample.Windows/Resizetizer.Extensions.Sample.Windows.csproj @@ -1,4 +1,4 @@ - + WinExe net7.0-windows10.0.19041.0 @@ -77,7 +77,7 @@ <_ResizetizerManifestPath>$(_UnoIntermediateManifest)Package.appxmanifest <_ResizetizerSplashScreenPath>$(_UnoIntermediateSplashScreen)splash_screen.scale-150.png <_ResizetizerAppIconPath>$(_UnoIntermediateImages)iconapp.ico - <_ResizetizerAppIconImagesPath>$(_UnoIntermediateImages)Images\iconappLogo.scale-150.png + <_ResizetizerAppIconImagesPath>$(_UnoIntermediateImages)Icons\iconappLogo.scale-150.png From 303b704a12a0ff997913dbc95d1482b860e21fd0 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Mon, 14 Aug 2023 13:54:15 -0300 Subject: [PATCH 08/18] test: updated unit tests to match the current changes --- .../GeneratePackageAppxManifestTests.cs | 24 +++++++++++++++---- .../test/UnitTests/ResizetizeImagesTests.cs | 2 +- .../appxmanifest/typical.appxmanifest | 6 ++--- .../typicalWithNoBackground.appxmanifest | 6 ++--- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs index 72164f15b459..2d5e1adc32dd 100644 --- a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs +++ b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs @@ -18,8 +18,14 @@ protected GeneratePackageAppxManifest_v0 GetNewTask( string? version = null, string? displayName = null, ITaskItem? appIcon = null, - ITaskItem? splashScreen = null) => - new() + ITaskItem? splashScreen = null) + { + new ResizetizeImages_v0() + { + TargetFramework = "windows" + }; + + return new() { IntermediateOutputPath = DestinationDirectory, BuildEngine = this, @@ -32,6 +38,7 @@ protected GeneratePackageAppxManifest_v0 GetNewTask( AppIcon = appIcon == null ? null : new[] { appIcon }, SplashScreen = splashScreen == null ? null : new[] { splashScreen }, }; + } [Theory] [InlineData(null, "Package.appxmanifest")] @@ -80,13 +87,20 @@ public void ManifestTakesPriority() } } + static void SetTargetFrameworkToWindows() + { + var property = typeof(ResizetizeImages_v0).GetProperty("_TargetFramework", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)!; + property.SetValue(null, "windows"); + } + [Fact] public void CorrectGenerationWhenUserSpecifyBackgroundColor() { var input = "empty"; var expected = "typicalWithNoBackground"; - var appIcon = new TaskItem("images/appicon.svg"); - appIcon.SetMetadata("ForegroundFile", "images/appiconfg.svg"); + var appIcon = new TaskItem("C:\\Git\\uno.resizetizer\\src\\Resizetizer\\test\\UnitTests\\images\\appicon.svg"); + appIcon.SetMetadata("ForegroundFile", "C:\\Git\\uno.resizetizer\\src\\Resizetizer\\test\\UnitTests\\images\\appiconfg.svg"); + appIcon.SetMetadata("ProjectDirectory", "C:\\Git\\uno.resizetizer\\src\\Resizetizer\\test\\UnitTests\\"); appIcon.SetMetadata("IsAppIcon", "true"); var splashScreen = new TaskItem("images/dotnet_bot.svg"); @@ -102,6 +116,8 @@ public void CorrectGenerationWhenUserSpecifyBackgroundColor() appIcon: appIcon, splashScreen: splashScreen); + SetTargetFrameworkToWindows(); + var success = task.Execute(); Assert.True(success, $"{task.GetType()}.Execute() failed: " + LogErrorEvents.FirstOrDefault()?.Message); diff --git a/src/Resizetizer/test/UnitTests/ResizetizeImagesTests.cs b/src/Resizetizer/test/UnitTests/ResizetizeImagesTests.cs index e3e5fc6b1e20..d2be246f88e6 100644 --- a/src/Resizetizer/test/UnitTests/ResizetizeImagesTests.cs +++ b/src/Resizetizer/test/UnitTests/ResizetizeImagesTests.cs @@ -1023,7 +1023,7 @@ public void AppIconWithBackgroundSucceedsWithVectors(string fg, string bg) var task = GetNewTask(items); var success = task.Execute(); Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); - bg = "Images\\" + bg; + AssertFileSize($"{bg}Logo.scale-100.png", 44, 44); AssertFileSize($"{bg}Logo.scale-125.png", 55, 55); AssertFileSize($"{bg}Logo.scale-200.png", 88, 88); diff --git a/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typical.appxmanifest b/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typical.appxmanifest index b3fe21054fcd..96eb31686bb0 100644 --- a/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typical.appxmanifest +++ b/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typical.appxmanifest @@ -7,7 +7,7 @@ .NET Foundation Sample App - Images/appiconStoreLogo.png + images\appiconStoreLogo.png @@ -18,8 +18,8 @@ - - + + diff --git a/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typicalWithNoBackground.appxmanifest b/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typicalWithNoBackground.appxmanifest index f415fe5ef1cd..585a344e0a69 100644 --- a/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typicalWithNoBackground.appxmanifest +++ b/src/Resizetizer/test/UnitTests/testdata/appxmanifest/typicalWithNoBackground.appxmanifest @@ -7,7 +7,7 @@ .NET Foundation Sample App - Images/appiconStoreLogo.png + images\appiconStoreLogo.png @@ -18,8 +18,8 @@ - - + + From ee2d05dfbd455328271de0c62bc1457c046cc7bc Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Tue, 15 Aug 2023 17:42:45 -0300 Subject: [PATCH 09/18] fix: changed the TargetFramework value on the right moment --- src/.nuspec/Uno.Resizetizer.windows.skia.targets | 1 + src/Resizetizer/src/GeneratePackageAppxManifest.cs | 3 +++ src/Resizetizer/src/ResizetizeImages.cs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/.nuspec/Uno.Resizetizer.windows.skia.targets b/src/.nuspec/Uno.Resizetizer.windows.skia.targets index d4e14ff64922..b16ed1bfeb33 100644 --- a/src/.nuspec/Uno.Resizetizer.windows.skia.targets +++ b/src/.nuspec/Uno.Resizetizer.windows.skia.targets @@ -65,6 +65,7 @@ ApplicationVersion="$(ApplicationVersion)" ApplicationTitle="$(ApplicationTitle)" AppIcon="@(UnoImage->WithMetadataValue('IsAppIcon', 'true'))" + TargetFramework="$(_UnoResizetizerPlatformIdentifier)" SplashScreen="@(UnoSplashScreen)"/> diff --git a/src/Resizetizer/src/GeneratePackageAppxManifest.cs b/src/Resizetizer/src/GeneratePackageAppxManifest.cs index 3f4a8163caf7..0fd8e5e0d196 100644 --- a/src/Resizetizer/src/GeneratePackageAppxManifest.cs +++ b/src/Resizetizer/src/GeneratePackageAppxManifest.cs @@ -26,6 +26,8 @@ public class GeneratePackageAppxManifest_v0 : Task [Required] public ITaskItem AppxManifest { get; set; } = null!; + public string? TargetFramework { get; set; } + public string? GeneratedFilename { get; set; } public string? ApplicationId { get; set; } @@ -50,6 +52,7 @@ public override bool Execute() #endif try { + ResizetizeImages_v0._TargetFramework = TargetFramework; Directory.CreateDirectory(IntermediateOutputPath); var filename = Path.Combine(IntermediateOutputPath, GeneratedFilename ?? "Package.appxmanifest"); diff --git a/src/Resizetizer/src/ResizetizeImages.cs b/src/Resizetizer/src/ResizetizeImages.cs index 1acb160a2ced..19f1a9a8674e 100644 --- a/src/Resizetizer/src/ResizetizeImages.cs +++ b/src/Resizetizer/src/ResizetizeImages.cs @@ -25,7 +25,7 @@ public class ResizetizeImages_v0 : UnoAsyncTask, ILogger public string TargetFramework { get; set; } - internal static string _TargetFramework { get; private set; } + internal static string _TargetFramework { get; set; } internal static string TargetPlatform { get; private set; } From 4fba07b55fbc60c870684e66f67d50be751db1b8 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Tue, 15 Aug 2023 17:43:10 -0300 Subject: [PATCH 10/18] test: updated unitTest --- .../GeneratePackageAppxManifestTests.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs index 2d5e1adc32dd..a9802dd2bbb8 100644 --- a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs +++ b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs @@ -1,9 +1,9 @@ #nullable enable +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; using System.IO; using System.Linq; using System.Xml.Linq; -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; using Xunit; namespace Uno.Resizetizer.Tests @@ -20,11 +20,6 @@ protected GeneratePackageAppxManifest_v0 GetNewTask( ITaskItem? appIcon = null, ITaskItem? splashScreen = null) { - new ResizetizeImages_v0() - { - TargetFramework = "windows" - }; - return new() { IntermediateOutputPath = DestinationDirectory, @@ -37,6 +32,7 @@ protected GeneratePackageAppxManifest_v0 GetNewTask( ApplicationTitle = displayName, AppIcon = appIcon == null ? null : new[] { appIcon }, SplashScreen = splashScreen == null ? null : new[] { splashScreen }, + TargetFramework = "windows" }; } @@ -87,12 +83,6 @@ public void ManifestTakesPriority() } } - static void SetTargetFrameworkToWindows() - { - var property = typeof(ResizetizeImages_v0).GetProperty("_TargetFramework", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)!; - property.SetValue(null, "windows"); - } - [Fact] public void CorrectGenerationWhenUserSpecifyBackgroundColor() { @@ -116,8 +106,6 @@ public void CorrectGenerationWhenUserSpecifyBackgroundColor() appIcon: appIcon, splashScreen: splashScreen); - SetTargetFrameworkToWindows(); - var success = task.Execute(); Assert.True(success, $"{task.GetType()}.Execute() failed: " + LogErrorEvents.FirstOrDefault()?.Message); From 707985e5757bf49cb175dd8f18e2f26829b8279f Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Tue, 15 Aug 2023 17:53:16 -0300 Subject: [PATCH 11/18] docs: updated docs with the most recent property --- doc/uno-resizetizer-properties.md | 3 ++- doc/using-uno-resizetizer.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/uno-resizetizer-properties.md b/doc/uno-resizetizer-properties.md index 46ddec15fbf1..72c5b9f94090 100644 --- a/doc/uno-resizetizer-properties.md +++ b/doc/uno-resizetizer-properties.md @@ -22,7 +22,7 @@ Properties that can be used across all items | Link | Used to specify a custom path for your image, this path should be used inside your application when you want to reference the image | | Resize | Boolean value to say if the asset should Resized or not. By default just vectors asset are resized by default | | TintColor | Color that will be used to tint the image during the resize phase. You can use a Hex value or a named value like `Fuchsia` | -| Color | Color that will be used as a background color | +| Color | Color that will be used as a background color | ## UnoIcon @@ -36,6 +36,7 @@ Properties that can be used across all items | WindowsForegroundScale | The same as ForegroundScale, but the value will be applied just for Windows | | IOSForegroundScale | The same as ForegroundScale, but the value will be applied just for iOS | | SkiaForegroundScale | The same as ForegroundScale, but the value will be applied just for Skia targets | +| ProjectDirectory | Used to specify the path of the file where UnoIcon is defined, it helps Resizetizer to find the full path of the app icon asset | > [!NOTE] > The PlatformsForegroundScale (AndroidForegroundScale, WasmForegroundScale, etc) will override the global ForegroundScale value. diff --git a/doc/using-uno-resizetizer.md b/doc/using-uno-resizetizer.md index 9e2945e557dc..1f074a8d0038 100644 --- a/doc/using-uno-resizetizer.md +++ b/doc/using-uno-resizetizer.md @@ -104,7 +104,8 @@ During the creation of your `svg` file, please remember to make the `ViewBox` bi + Color="#FF0000" + ProjectDirectory="$(MSBuildThisFileDirectory)"/> ``` From b0c5d01a46661a38bce080004f3a5fa40d22c112 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Wed, 16 Aug 2023 13:54:07 -0300 Subject: [PATCH 12/18] test: updated path to work on CI --- .../test/UnitTests/GeneratePackageAppxManifestTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs index a9802dd2bbb8..297f12eb25bf 100644 --- a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs +++ b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs @@ -88,9 +88,9 @@ public void CorrectGenerationWhenUserSpecifyBackgroundColor() { var input = "empty"; var expected = "typicalWithNoBackground"; - var appIcon = new TaskItem("C:\\Git\\uno.resizetizer\\src\\Resizetizer\\test\\UnitTests\\images\\appicon.svg"); - appIcon.SetMetadata("ForegroundFile", "C:\\Git\\uno.resizetizer\\src\\Resizetizer\\test\\UnitTests\\images\\appiconfg.svg"); - appIcon.SetMetadata("ProjectDirectory", "C:\\Git\\uno.resizetizer\\src\\Resizetizer\\test\\UnitTests\\"); + var appIcon = new TaskItem("images\\appicon.svg"); + appIcon.SetMetadata("ForegroundFile", "images\\appiconfg.svg"); + appIcon.SetMetadata("ProjectDirectory", Directory.GetCurrentDirectory() + "\\"); appIcon.SetMetadata("IsAppIcon", "true"); var splashScreen = new TaskItem("images/dotnet_bot.svg"); From 6e8739b2918d4212f718dcbdb4e0f031a05f0ad5 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 15 Sep 2023 20:36:02 -0300 Subject: [PATCH 13/18] chore: reverted file to previous state --- src/Resizetizer/src/ResizeImageInfo.cs | 29 +++----------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/Resizetizer/src/ResizeImageInfo.cs b/src/Resizetizer/src/ResizeImageInfo.cs index 62e65d13c0f7..04d03a376462 100644 --- a/src/Resizetizer/src/ResizeImageInfo.cs +++ b/src/Resizetizer/src/ResizeImageInfo.cs @@ -83,40 +83,17 @@ public static List Parse(IEnumerable? images) throw new FileNotFoundException("Unable to find background file: " + fileInfo.FullName, fileInfo.FullName); } - if (bool.TryParse(image.GetMetadata(nameof(IsAppIcon)), out var iai)) - { - info.IsAppIcon = iai; - } - info.Filename = fileInfo.FullName; info.Alias = image.GetMetadata("Link"); if (string.IsNullOrWhiteSpace(info.Alias)) { - var windowsAndAppIcon = ResizetizeImages_v0._TargetFramework == "windows" && info.IsAppIcon; - - if (!windowsAndAppIcon) - { - var projDirectory = image.GetMetadata("DefiningProjectDirectory"); + var projDirectory = image.GetMetadata("DefiningProjectDirectory"); - if (!string.IsNullOrWhiteSpace(projDirectory)) - { - info.Alias = fileInfo.FullName.Replace(projDirectory, string.Empty); - } - } - else + if (!string.IsNullOrWhiteSpace(projDirectory)) { - -#if DEBUG_RESIZETIZER - System.Diagnostics.Debugger.Launch(); -#endif - var projDirectory = image.GetMetadata("ProjectDirectory"); - - if (!string.IsNullOrWhiteSpace(projDirectory)) - { - info.Alias = fileInfo.FullName.Replace(projDirectory, string.Empty); - } + info.Alias = fileInfo.FullName.Replace(projDirectory, string.Empty); } } From f2b34e27c2aa75b929a325b2358d1828719ca4c6 Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Fri, 15 Sep 2023 20:36:46 -0300 Subject: [PATCH 14/18] fix: Find the relative path of the appicon Use AssignLinkMetadata to do that --- src/.nuspec/Uno.Resizetizer.targets | 4 ++-- src/.nuspec/Uno.Resizetizer.windows.skia.targets | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/.nuspec/Uno.Resizetizer.targets b/src/.nuspec/Uno.Resizetizer.targets index cdecc620bcbe..e84d3751ce9f 100644 --- a/src/.nuspec/Uno.Resizetizer.targets +++ b/src/.nuspec/Uno.Resizetizer.targets @@ -262,7 +262,7 @@ <_WindowIconExtension Include="$(_UnoResizetizerIntermediateOutputRoot)Uno.Resizetizer.WindowIconExtensions.g.cs"/> - + @@ -317,7 +317,7 @@ - + diff --git a/src/.nuspec/Uno.Resizetizer.windows.skia.targets b/src/.nuspec/Uno.Resizetizer.windows.skia.targets index b16ed1bfeb33..169f33c97441 100644 --- a/src/.nuspec/Uno.Resizetizer.windows.skia.targets +++ b/src/.nuspec/Uno.Resizetizer.windows.skia.targets @@ -1,5 +1,20 @@ + + + + + + + + + + + + Date: Fri, 15 Sep 2023 20:37:05 -0300 Subject: [PATCH 15/18] test: update tests to reflect changes --- .../Resizetizer.Extensions.Sample.Skia.WPF.csproj | 2 +- .../test/UnitTests/GeneratePackageAppxManifestTests.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj b/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj index d94bd504ce5f..3be5d8ff1549 100644 --- a/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj +++ b/samples/NewTemplate/Resizetizer.Extensions.Sample.Skia.WPF/Resizetizer.Extensions.Sample.Skia.WPF.csproj @@ -43,7 +43,7 @@ <_ResizetizerSplashScreenPath>$(_UnoIntermediateImages)splash_screen.scale-125.png <_ResizetizerAppIconPath>$(_UnoIntermediateImages)iconapp.ico - <_ResizetizerAppIconImagesPath>$(_UnoIntermediateImages)\Icons\iconapp.png + <_ResizetizerAppIconImagesPath>$(_UnoIntermediateImages)iconapp.png diff --git a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs index 297f12eb25bf..58966c12e809 100644 --- a/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs +++ b/src/Resizetizer/test/UnitTests/GeneratePackageAppxManifestTests.cs @@ -1,6 +1,7 @@ #nullable enable using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Linq; @@ -90,7 +91,7 @@ public void CorrectGenerationWhenUserSpecifyBackgroundColor() var expected = "typicalWithNoBackground"; var appIcon = new TaskItem("images\\appicon.svg"); appIcon.SetMetadata("ForegroundFile", "images\\appiconfg.svg"); - appIcon.SetMetadata("ProjectDirectory", Directory.GetCurrentDirectory() + "\\"); + appIcon.SetMetadata("Link", "images\\appicon.svg"); appIcon.SetMetadata("IsAppIcon", "true"); var splashScreen = new TaskItem("images/dotnet_bot.svg"); @@ -106,6 +107,8 @@ public void CorrectGenerationWhenUserSpecifyBackgroundColor() appIcon: appIcon, splashScreen: splashScreen); + + var success = task.Execute(); Assert.True(success, $"{task.GetType()}.Execute() failed: " + LogErrorEvents.FirstOrDefault()?.Message); From 6f1a1d7dedd42b9ed2945117550528cb3b61c76e Mon Sep 17 00:00:00 2001 From: Pedro Jesus Date: Thu, 21 Sep 2023 13:13:30 -0300 Subject: [PATCH 16/18] chore: removed unused properties on docs and base.props --- doc/uno-resizetizer-properties.md | 1 - doc/using-uno-resizetizer.md | 3 +-- .../NewTemplate/Resizetizer.Extensions.Sample.Base/base.props | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/uno-resizetizer-properties.md b/doc/uno-resizetizer-properties.md index 72c5b9f94090..0227a41398f4 100644 --- a/doc/uno-resizetizer-properties.md +++ b/doc/uno-resizetizer-properties.md @@ -36,7 +36,6 @@ Properties that can be used across all items | WindowsForegroundScale | The same as ForegroundScale, but the value will be applied just for Windows | | IOSForegroundScale | The same as ForegroundScale, but the value will be applied just for iOS | | SkiaForegroundScale | The same as ForegroundScale, but the value will be applied just for Skia targets | -| ProjectDirectory | Used to specify the path of the file where UnoIcon is defined, it helps Resizetizer to find the full path of the app icon asset | > [!NOTE] > The PlatformsForegroundScale (AndroidForegroundScale, WasmForegroundScale, etc) will override the global ForegroundScale value. diff --git a/doc/using-uno-resizetizer.md b/doc/using-uno-resizetizer.md index 1f074a8d0038..9e2945e557dc 100644 --- a/doc/using-uno-resizetizer.md +++ b/doc/using-uno-resizetizer.md @@ -104,8 +104,7 @@ During the creation of your `svg` file, please remember to make the `ViewBox` bi + Color="#FF0000"/> ``` diff --git a/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props b/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props index a8a35e61472d..979f0902b515 100644 --- a/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props +++ b/samples/NewTemplate/Resizetizer.Extensions.Sample.Base/base.props @@ -13,8 +13,7 @@ + Color="#00000000" /> Date: Thu, 21 Sep 2023 15:34:51 -0300 Subject: [PATCH 17/18] fix: fixed validation order to avoid false warning --- src/.nuspec/Uno.Resizetizer.targets | 46 +++++++++++-------- .../Uno.Resizetizer.windows.skia.targets | 1 + 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/.nuspec/Uno.Resizetizer.targets b/src/.nuspec/Uno.Resizetizer.targets index e84d3751ce9f..716afe0b4131 100644 --- a/src/.nuspec/Uno.Resizetizer.targets +++ b/src/.nuspec/Uno.Resizetizer.targets @@ -262,7 +262,32 @@ <_WindowIconExtension Include="$(_UnoResizetizerIntermediateOutputRoot)Uno.Resizetizer.WindowIconExtensions.g.cs"/> - + + + + + + + + + + + + + + + + @@ -312,8 +337,6 @@ - @@ -372,23 +395,6 @@ Inputs="$(_UnoSplashInputsFile);@(UnoSplashScreen)" Outputs="$(_UnoSplashStampFile)"> - - - - - - - - - diff --git a/src/.nuspec/Uno.Resizetizer.windows.skia.targets b/src/.nuspec/Uno.Resizetizer.windows.skia.targets index 169f33c97441..22d17e0849b6 100644 --- a/src/.nuspec/Uno.Resizetizer.windows.skia.targets +++ b/src/.nuspec/Uno.Resizetizer.windows.skia.targets @@ -3,6 +3,7 @@ From 5d5211000e4ef86fce0a93ca3ccd96c355c533bb Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Fri, 22 Sep 2023 16:34:58 +1000 Subject: [PATCH 18/18] chore: Formatting and adding UnoIcon count warning --- src/.nuspec/Uno.Resizetizer.targets | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/.nuspec/Uno.Resizetizer.targets b/src/.nuspec/Uno.Resizetizer.targets index 716afe0b4131..1795a1d2bec2 100644 --- a/src/.nuspec/Uno.Resizetizer.targets +++ b/src/.nuspec/Uno.Resizetizer.targets @@ -267,25 +267,29 @@ - + + Condition="'@(UnoIcon->Count())' > '1'" + Text="More than one 'UnoIcon' is defined; only the first will be used." /> + + + + - - - + Text="The value of UnoSplashScreen and UnoIcon.ForegroundFile cannot be the same."/>