[Build] Expose processed fonts and assets for custom platform backends#34227
[Build] Expose processed fonts and assets for custom platform backends#34227
Conversation
Add MauiProcessedFont and MauiProcessedAsset public item groups so custom platform backends can consume processed resources via AfterTargets without re-implementing font/asset copy logic. Add a default _MauiAssetItemMetadata fallback to 'Link' for platforms not explicitly listed (Android, iOS, Windows, Tizen). Fixes #34221 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Resizetizer build targets to expose the results of font and asset processing so custom platform backends can consume the resolved/copied items without re-implementing that logic.
Changes:
- Adds a default fallback for
_MauiAssetItemMetadatatoLinkwhen no known platform match is detected. - Exposes resolved assets as a public
@(MauiProcessedAsset)item group afterGetMauiAssetPathruns. - Exposes copied fonts as a public
@(MauiProcessedFont)item group after the font copy step.
| <!-- Expose processed fonts for custom platform backends --> | ||
| <ItemGroup> | ||
| <MauiProcessedFont Include="@(_MauiFontCopied)" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
MauiProcessedFont is populated from @(_MauiFontCopied), which is created via the wildcard $(_MauiIntermediateFonts)*. Since this directory also contains non-font outputs (e.g., MauiInfo.plist is generated into the same folder on iOS), incremental builds can leave extra files there and the wildcard will include them. That means custom backends consuming @(MauiProcessedFont) may end up bundling non-font files. Consider populating MauiProcessedFont from the Copy task's CopiedFiles output (or otherwise filtering @(_MauiFontCopied) to only .ttf/.otf etc.) so only actual font files are exposed.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description
The Resizetizer's
ProcessMauiFontsandProcessMauiAssetstargets perform fundamentally platform-agnostic work (copying font files, resolving asset paths) but don't expose their results for consumption by custom platform backends.This PR makes three small changes to
Microsoft.Maui.Resizetizer.After.targets:1.
MauiProcessedFontpublic item groupAfter
ProcessMauiFontscopies fonts to the intermediate directory, the copied files are exposed asMauiProcessedFontitems. Custom backends can consume viaAfterTargets="ProcessMauiFonts":2.
MauiProcessedAssetpublic item groupAfter
ProcessMauiAssetsrunsGetMauiAssetPath, the resolved assets are exposed asMauiProcessedAssetitems.3. Default
_MauiAssetItemMetadatafallbackWhen no known platform matches (Android, iOS, Windows, Tizen),
_MauiAssetItemMetadatanow defaults toLinkinstead of being empty, which would causeGetMauiAssetPathto fail or produce no useful output.Impact
Fixes #34221
Part of #34099