-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Handle renamed or deleted MauiImage files #13251
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
Changes from all commits
79babb8
7be55f8
d197115
689aa0a
5b8bbf1
472792b
49f088e
dfba4e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -386,6 +386,7 @@ | |
| MauiSplashScreen="@(MauiSplashScreen)" | ||
| InputsFile="$(_MauiSplashInputsFile)" | ||
| /> | ||
|
|
||
| <ItemGroup Condition="'$(_ResizetizerIsAndroidApp)' == 'True' and '$(_MauiHasSplashScreens)' == 'true'"> | ||
| <_MauiSplashAssets Include="$(_MauiIntermediateSplashScreen)**\*" /> | ||
| <LibraryResourceDirectories Condition="Exists('$(_MauiIntermediateSplashScreen)')" Include="$(_MauiIntermediateSplashScreen)"> | ||
|
|
@@ -579,15 +580,25 @@ | |
| IntermediateOutputPath="$(_MauiIntermediateImages)" | ||
| InputsFile="$(_ResizetizerInputsFile)" | ||
| Images="@(MauiImage->Distinct())"> | ||
| <Output TaskParameter="CopiedResources" ItemName="_CopiedResources" /> | ||
| </ResizetizeImages> | ||
|
|
||
| <ItemGroup> | ||
| <!-- Get Images that were generated --> | ||
| <!-- Either from the task, or if the task was skipped (up to date), use the wildcard lookup --> | ||
| <_ResizetizerCollectedImages Condition="'@(CopiedResources)' != ''" Include="@(CopiedResources)" /> | ||
| <_ResizetizerCollectedImages Condition="'@(CopiedResources)' == ''" Include="$(_MauiIntermediateImages)**\*" /> | ||
| <_ResizetizerCollectedImages Condition="'@(_CopiedResources->Count())' != '0'" Include="@(_CopiedResources)" /> | ||
| <_ResizetizerExistingImages Include="$(_MauiIntermediateImages)\**\*" /> | ||
| <_ResizetizerImagesToDelete Include="@(_ResizetizerExistingImages->'%(FullPath)')" /> | ||
| <_ResizetizerCollectedImages Condition="'@(_CopiedResources)' == ''" Include="@(_ResizetizerExistingImages->'%(FullPath)')" /> | ||
|
Comment on lines
+591
to
+592
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these actually need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to use |
||
| <_ResizetizerImagesToDelete Remove="@(_ResizetizerCollectedImages)" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- Remove files which are no longer needed --> | ||
| <Delete | ||
| Condition="'@(_ResizetizerImagesToDelete->Count())' != '0'" | ||
| Files="@(_ResizetizerImagesToDelete)" | ||
| /> | ||
|
|
||
| <!-- iOS --> | ||
| <ItemGroup Condition="'$(_ResizetizerIsiOSApp)' == 'True'"> | ||
| <!-- Batch the collectd items into BundleResource which iOS expects --> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -676,6 +676,43 @@ public void DiffPropoprtionAppIconWithoutBaseUseBackgroundSize(double fgScale, s | |
| AssertFileMatches($"mipmap-xhdpi/{Path.GetFileNameWithoutExtension(bg)}_foreground.png", new object[] { fgScale, bg, fg, "xh", "f" }); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void NonExistantFilesAreDeleted() | ||
| { | ||
| var items = new[] | ||
| { | ||
| new TaskItem("images/camera.svg", new Dictionary<string, string> | ||
| { | ||
| ["Link"] = "dog", | ||
| }), | ||
| }; | ||
|
|
||
| var task = GetNewTask(items); | ||
| var success = task.Execute(); | ||
| Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); | ||
|
|
||
| AssertFileNotExists("drawable-hdpi/cat.png"); | ||
| AssertFileExists("drawable-hdpi/dog.png"); | ||
|
|
||
| LogErrorEvents.Clear(); | ||
| LogMessageEvents.Clear(); | ||
|
|
||
| items = new[] | ||
| { | ||
| new TaskItem("images/camera.svg", new Dictionary<string, string> | ||
| { | ||
| ["Link"] = "cat", | ||
| }), | ||
| }; | ||
|
|
||
| task = GetNewTask(items); | ||
| success = task.Execute(); | ||
| Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); | ||
|
|
||
| AssertFileNotExists("drawable-hdpi/dot.png"); | ||
| AssertFileExists("drawable-hdpi/cat.png"); | ||
| } | ||
|
|
||
| //[Theory] | ||
| //[InlineData(1, 1, "dotnet_background.svg", "tall_image.png", 300, 300)] | ||
| //[InlineData(1, 1, "dotnet_background.svg", "wide_image.png", 300, 300)] | ||
|
|
@@ -1015,6 +1052,43 @@ public void SingleVectorAppIconWithOnlyPathSucceedsWithVectors(string name, stri | |
| $"\"filename\": \"{outputName}[email protected]\"", | ||
| $"\"size\": \"20x20\","); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void NonExistantFilesAreDeleted() | ||
| { | ||
| var items = new[] | ||
| { | ||
| new TaskItem("images/camera.svg", new Dictionary<string, string> | ||
| { | ||
| ["Link"] = "dog", | ||
| }), | ||
| }; | ||
|
|
||
| var task = GetNewTask(items); | ||
| var success = task.Execute(); | ||
| Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); | ||
|
|
||
| AssertFileNotExists("cat.png"); | ||
| AssertFileExists("dog.png"); | ||
|
|
||
| LogErrorEvents.Clear(); | ||
| LogMessageEvents.Clear(); | ||
|
|
||
| items = new[] | ||
| { | ||
| new TaskItem("images/camera.svg", new Dictionary<string, string> | ||
| { | ||
| ["Link"] = "cat", | ||
| }), | ||
| }; | ||
|
|
||
| task = GetNewTask(items); | ||
| success = task.Execute(); | ||
| Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); | ||
|
|
||
| AssertFileNotExists("dot.png"); | ||
| AssertFileExists("cat.png"); | ||
| } | ||
| } | ||
|
|
||
| public class ExecuteForWindows : ExecuteForApp | ||
|
|
@@ -1335,6 +1409,43 @@ public void ColorsInCssCanBeUsed() | |
|
|
||
| AssertFileContains("not_working.scale-100.png", 0xFF71559B, 2, 6); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void NonExistantFilesAreDeleted() | ||
| { | ||
| var items = new[] | ||
| { | ||
| new TaskItem("images/camera.svg", new Dictionary<string, string> | ||
| { | ||
| ["Link"] = "dog", | ||
| }), | ||
| }; | ||
|
|
||
| var task = GetNewTask(items); | ||
| var success = task.Execute(); | ||
| Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); | ||
|
|
||
| AssertFileNotExists("cat.scale-150.png"); | ||
| AssertFileExists("dog.scale-150.png"); | ||
|
|
||
| LogErrorEvents.Clear(); | ||
| LogMessageEvents.Clear(); | ||
|
|
||
| items = new[] | ||
| { | ||
| new TaskItem("images/camera.svg", new Dictionary<string, string> | ||
| { | ||
| ["Link"] = "cat", | ||
| }), | ||
| }; | ||
|
|
||
| task = GetNewTask(items); | ||
| success = task.Execute(); | ||
| Assert.True(success, LogErrorEvents.FirstOrDefault()?.Message); | ||
|
|
||
| AssertFileNotExists("dot.scale-150.png"); | ||
| AssertFileExists("cat.scale-150.png"); | ||
| } | ||
| } | ||
|
|
||
| public class ExecuteForAny : ExecuteForApp | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other thing, is it possible for
$(_MauiIntermediateImages)to ever be blank?If it ever was, this would wildcard your entire drive like
\**\*.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is set here
maui/src/SingleProject/Resizetizer/src/nuget/buildTransitive/Microsoft.Maui.Resizetizer.After.targets
Line 71 in dfba4e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we could rely on it ending with a trailing
\, then at worst it would wildcard**\*in the current directory instead of the whole drive.But this is kind of unrelated to this change, we don't really have to fix it here.