Repository navigation
Description
Summary
When a .NET file-based (single-file) WinUI app is run packaged through Microsoft.Windows.SDK.BuildTools.WinApp (dotnet run App.cs / winapp run App.cs), the app icon is wrong in two places compared to the same app built from a .csproj:
- Taskbar icon is drawn on an accent-colored plate instead of the clean unplated icon.
- The window title bar has no icon.
Found while testing the new reactor-singlefile template in microsoft/WindowsAppSDK#6844 side by side with the four existing Reactor .csproj templates.
Repro
- .NET SDK 10.0.401, Developer Mode on
Microsoft.Windows.SDK.BuildTools.WinApp0.7.1,Microsoft.WindowsAppSDK2.5.1,Microsoft.UI.Reactor0.1.0-preview.16
dotnet new reactor-singlefile -n SingleFileDemo # template pack from microsoft/WindowsAppSDK#6844
cd SingleFileDemo
dotnet run SingleFileDemo.csCompare with dotnet new reactor -n BlankDemo; cd BlankDemo; dotnet run.
Findings
1. Taskbar plate: the generated assets aren't indexed in resources.pri
winapp synthesizes the manifest (Square44x44Logo="Assets\AppList.png", BackgroundColor="transparent") and writes the assets to %TEMP%\dotnet\runfile\<app>-<hash>\bin\debug\AppX\Assets\, including AppList.targetsize-24_altform-unplated.png. But the resources.pri generated next to it doesn't index any of the Assets\AppList* files: there are no TARGETSIZE or ALTFORM qualifiers in it at all.
Because the shell can't resolve an unplated targetsize variant through MRT, it falls back to the plated logo and draws it on a plate in the user's accent color (BackgroundColor="transparent" means accent).
For comparison, the .csproj app's resources.pri indexes Square44x44Logo.png, .scale-200, .targetsize-24_altform-unplated and .targetsize-48_altform-lightunplated, and its taskbar icon is unplated.
Also worth checking: only a targetsize-24 unplated variant is generated for the single-file path. The taskbar at higher DPI, and light theme, look for other sizes (e.g. 32/48) and altform-lightunplated.
2. Title bar: the exe has no embedded icon
The WinUI title bar icon comes from the exe's embedded Win32 icon resource. .csproj templates set <ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>. A file-based app has no .ico and no ApplicationIcon, so the apphost exe has no icon and the title bar is empty. winapp already produces an app.ico in manifest update-assets, but the single-file run path doesn't generate one or set ApplicationIcon.
Expected
A single-file app run through winapp should look the same as the .csproj equivalent:
- unplated taskbar icon, with generated assets indexed in
resources.priacross the usualtargetsizeandaltform-unplated/lightunplatedvariants - a title bar icon, from a generated default
.icowired up asApplicationIconwhen the user hasn't set one
The template can't fix this on its own without adding files next to the .cs, which defeats the purpose of a single-file template.
Pointers
src/winapp-CLI/WinApp.Cli/Services/ImageAssetService.cs(asset and unplated variant generation)src/winapp-CLI/WinApp.Cli/Services/PriService.cs/MrtAssetHelper.cs(PRI indexing)- The
WinAppRunSupportMSBuild path used for file-based apps (Run a .NET file-based app with package identity #794, Support packaged dotnet run for .NET file-based apps #874)
Activity
Fix plated taskbar icon and missing title bar icon for file-based apps
Fix plated taskbar icon and missing title bar icon for file-based apps (