Repository navigation
Description
Description
When a MAUI app is referenced as a library via ProjectReference with AdditionalProperties to suppress items like MauiIcon and MauiSplashScreen, Resizetizer's ResizetizeCollectItems target ignores those properties when calling GetMauiItems on the referenced project.
Steps to Reproduce
- Have a MAUI app project that conditionally strips
MauiIcon/MauiSplashScreenwhen a property is set:
<ItemGroup Condition="'$(IsTestLibrary)' == 'true'">
<MauiIcon Remove="@(MauiIcon)" />
<MauiSplashScreen Remove="@(MauiSplashScreen)" />
</ItemGroup>- Reference it from a test project with AdditionalProperties:
<ProjectReference Include="..\MyApp\MyApp.csproj">
<AdditionalProperties>IsTestLibrary=true</AdditionalProperties>
</ProjectReference>-
The test project has its own
MauiIconwith a different filename. -
Build β error:
One or more duplicate file names were detected. All image output filenames must be unique: appicon
Root Cause
In Microsoft.Maui.Resizetizer.After.targets, the ResizetizeCollectItems target calls:
<MSBuild
Targets="GetMauiItems"
Projects="%(_ResizetizeCollectItemsProject.Identity)"
Properties="TargetFramework=%(_ResizetizeCollectItemsProject.NearestTargetFramework)"
...>It only passes TargetFramework β it does not propagate AdditionalProperties or any other metadata from the original ProjectReference item. This means the referenced project evaluates GetMauiItems without the user's properties, so the conditional Remove never fires and the app's MauiIcon/MauiSplashScreen leak into the consuming project.
Expected Behavior
ResizetizeCollectItems should propagate AdditionalProperties (and/or SetConfiguration/SetPlatform) from the ProjectReference items when invoking GetMauiItems, similar to how the standard build graph respects these properties.
Workaround
Consuming projects must add a target to strip the imported items after collection:
<Target Name="_RemoveImportedAppIcon" AfterTargets="ResizetizeCollectItems">
<ItemGroup>
<MauiImage Remove="@(MauiImage)"
Condition="'\%(MauiImage.Filename)' == 'appicon' and '\%(MauiImage.IsAppIcon)' == 'True'" />
</ItemGroup>
</Target>Context
This pattern is increasingly common for device testing scenarios where a test app references the real app as a library to test controls/ViewModels with real styles and resources. Both mattleibow/DeviceRunners and pictos/DeviceAppTest independently hit this and implemented the same workaround.
Suggested Fix
In ResizetizeCollectItems, when building the _ResizetizeCollectItemsProject items, carry over the AdditionalProperties metadata from the original ProjectReference items and append them to the Properties parameter of the MSBuild task call.
Activity
Rewrite docs with drop-in targets and workaround explanation
Rewrite docs with drop-in targets and workaround explanation
Fix: Propagate AdditionalProperties from ProjectReference in Resizetiβ¦
Fix: Propagate AdditionalProperties from ProjectReference in Resizetiβ¦
Fix: Propagate AdditionalProperties from ProjectReference in Resizetiβ¦
Fix: Propagate AdditionalProperties from ProjectReference in Resizetiβ¦
Fix: Propagate AdditionalProperties from ProjectReference in Resizetiβ¦
Fix: Propagate AdditionalProperties from ProjectReference in Resizetiβ¦
June 8th, Candidate (#35716)