From 7ffc01136b50bb50f9f32066b9786ea3ccbb45ac Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Mon, 15 Apr 2024 11:25:02 +0100 Subject: [PATCH] Android mipmap/appicon failing with "APT2260" Context https://developercommunity.visualstudio.com/t/Android-mipmapappicon-failing-with-APT/10622494 Users are reporting this error quite allot. During a build it fails with the following error ``` APT2260 resource mipmap/appicon (aka xxx:mipmap/appicon) not found. ``` Further investigation this only appears to happen during a full build of all the platforms. Specifying `-f net8.0-android` on the build this does not seem to happen at all. The problem is the build gets into a weird situation where the `mauiimage.stamp` file is present but none of the generated images are. Considering that the stamp file gets generated AFTER the images its kinda difficult to see how this even occurs. The work around for this is to write the list of generated image files to `mauiimage.outputs`. We can then read this list back on subsequent builds and use that list for the `Outputs` of the `ResizetizeImages` target. This means the target will run if either the stamp file or any of the expected images are not present. --- .../Resizetizer/src/ResizetizeImages.cs | 2 ++ .../Microsoft.Maui.Resizetizer.After.targets | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/SingleProject/Resizetizer/src/ResizetizeImages.cs b/src/SingleProject/Resizetizer/src/ResizetizeImages.cs index efd069b67e24..90ac413fa579 100644 --- a/src/SingleProject/Resizetizer/src/ResizetizeImages.cs +++ b/src/SingleProject/Resizetizer/src/ResizetizeImages.cs @@ -118,6 +118,8 @@ public override System.Threading.Tasks.Task ExecuteAsync() attr.Add("_ResizetizerDpiScale", img.Dpi.Scale.ToString("0.0", CultureInfo.InvariantCulture)); copiedResources.Add(new TaskItem(itemSpec, attr)); + // force the date time so we never update an image if its not changed. + File.SetLastWriteTimeUtc (itemSpec, DateTime.UtcNow); } CopiedResources = copiedResources.ToArray(); 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 ada7852e6676..aa31e92b3d3d 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 @@ -60,6 +60,7 @@ <_ResizetizerInputsFile>$(IntermediateOutputPath)mauiimage.inputs + <_ResizetizerOutputsFile>$(IntermediateOutputPath)mauiimage.outputs <_ResizetizerStampFile>$(IntermediateOutputPath)mauiimage.stamp <_MauiFontInputsFile>$(IntermediateOutputPath)mauifont.inputs <_MauiFontStampFile>$(IntermediateOutputPath)mauifont.stamp @@ -115,6 +116,7 @@ $(ResizetizeDependsOnTargets); ResizetizeCollectItems; ProcessMauiSplashScreens; + _ReadResizetizeImagesOutputs; $(ProcessMauiFontsDependsOnTargets); @@ -601,10 +603,16 @@ + + + + + + @@ -720,10 +728,17 @@ + +