From b3b5062faace0dd6deed9558f9aaa3f3e53d546a Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Tue, 17 Oct 2023 03:32:24 +0200 Subject: [PATCH 1/4] Support finding nearest TFM to collect assets from --- .../Microsoft.Maui.Resizetizer.After.targets | 5 +- .../ResizetizerTests.cs | 96 +++++++++++++++++++ 2 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 src/TestUtils/src/Microsoft.Maui.IntegrationTests/ResizetizerTests.cs diff --git a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets index 2d7954d81318..2472864f6a6c 100644 --- a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets +++ b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets @@ -261,12 +261,11 @@ - + + + + """; + + [Test] + // windows unpackaged/exe + [TestCase("maui", "classlib", true)] // net8.0 + [TestCase("maui", "mauilib", true)] // net8.0-xxx + [TestCase("maui-blazor", "classlib", true)] // net8.0 + [TestCase("maui-blazor", "mauilib", true)] // net8.0-xxx + // windows packaged/msix + [TestCase("maui", "classlib", false)] // net8.0 + [TestCase("maui", "mauilib", false)] // net8.0-xxx + [TestCase("maui-blazor", "classlib", false)] // net8.0 + [TestCase("maui-blazor", "mauilib", false)] // net8.0-xxx + public void CollectsAssets(string id, string libid, bool unpackaged) + { + // new app + var appDir = Path.Combine(TestDirectory, "theapp"); + var appFile = Path.Combine(appDir, $"{Path.GetFileName(appDir)}.csproj"); + Assert.IsTrue(DotnetInternal.New(id, appDir, DotNetCurrent), + $"Unable to create template {id}. Check test output for errors."); + + // new lib + var libDir = Path.Combine(TestDirectory, "thelib"); + var libFile = Path.Combine(libDir, $"{Path.GetFileName(libDir)}.csproj"); + Assert.IsTrue(DotnetInternal.New(libid, libDir, DotNetCurrent), + $"Unable to create template {libid}. Check test output for errors."); + + // add a project reference + FileUtilities.ReplaceInFile(appFile, + "", + """ + + + + + """); + + // toggle packaged / unpackaged + if (unpackaged) + { + FileUtilities.ReplaceInFile(appFile, + "", + """ + + None + + + """); + + } + + // add the svg file + File.WriteAllText(Path.Combine(libDir, "the_image.svg"), BlankSvgContents); + + // add the + FileUtilities.ReplaceInFile(libFile, + "", + """ + + true + true + + + + + + """); + + // build + Assert.IsTrue(DotnetInternal.Build(appFile, "Debug", properties: BuildProps), + $"Project {Path.GetFileName(appFile)} failed to build. Check test output/attachments for errors."); + + // assert + Assert.True(File.Exists(Path.Combine(appDir, $"obj\\Debug\\{DotNetCurrent}-android\\resizetizer\\r\\drawable-mdpi\\the_image.png")), + "Android was missing the image file."); + Assert.True(File.Exists(Path.Combine(appDir, $"obj\\Debug\\{DotNetCurrent}-ios\\iossimulator-x64\\resizetizer\\r\\the_image.png")), + "iOS was missing the image file."); + Assert.True(File.Exists(Path.Combine(appDir, $"obj\\Debug\\{DotNetCurrent}-maccatalyst\\maccatalyst-x64\\resizetizer\\r\\the_image.png")), + "Mac Catalyst was missing the image file."); + if (TestEnvironment.IsWindows) + Assert.True(File.Exists(Path.Combine(appDir, $"obj\\Debug\\{DotNetCurrent}-windows10.0.19041.0\\win10-x64\\resizetizer\\r\\the_image.scale-100.png")), + "Windows was missing the image file."); + } +} From 3deb6faed7b3a2e7eeb593fe00362c2ce5d6d198 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 20 Oct 2023 04:22:36 +0800 Subject: [PATCH 2/4] Update Microsoft.Maui.Resizetizer.After.targets --- .../Microsoft.Maui.Resizetizer.After.targets | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets index 2472864f6a6c..5cfa1e5770b3 100644 --- a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets +++ b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets @@ -261,11 +261,15 @@ + + + + Date: Fri, 20 Oct 2023 19:42:57 +0800 Subject: [PATCH 3/4] Update Microsoft.Maui.Resizetizer.After.targets --- .../Microsoft.Maui.Resizetizer.After.targets | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets index 5cfa1e5770b3..2558fc92ae7d 100644 --- a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets +++ b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets @@ -256,28 +256,35 @@ + ItemName="_ImportedMauiItem" /> - - + - - + + + + + + + + + ItemName="_ImportedMauiItem" /> + From e010bd71ea2d2f9774b9c0287c901ce0ccc68868 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Fri, 20 Oct 2023 18:24:26 +0200 Subject: [PATCH 4/4] Update Microsoft.Maui.Resizetizer.After.targets --- .../Microsoft.Maui.Resizetizer.After.targets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets index 2558fc92ae7d..a08c3307e19c 100644 --- a/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets +++ b/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets @@ -262,20 +262,20 @@ - + <_ResizetizeCollectItemsProjectWithOIS Include="@(_ResolvedProjectReferencePaths->HasMetadata('OriginalProjectReferenceItemSpec'))" /> - + <_ResizetizeCollectItemsProjectWithItemSpec Include="@(_ResizetizeCollectItemsProjectWithOIS->'%(OriginalProjectReferenceItemSpec)')" /> - + <_ResizetizeCollectItemsProject Include="@(_ResizetizeCollectItemsProjectWithItemSpec->HasMetadata('NearestTargetFramework'))" /> - + <_ResizetizeCollectItemsProject Include="@(ProjectReference)" Exclude="@(_ResizetizeCollectItemsProject)" NearestTargetFramework="$(TargetFramework)" />