Dotnet Templates: use winappCli 3.0.1 (Microsoft.Windows.SDK.BuildTools.WinApp)#6455
Conversation
…SDK.BuildTools.WinApp for `dotnet run`
Reference the new `Microsoft.Windows.SDK.BuildTools.WinApp` NuGet package
(0.3.1) from the four packaged WinUI C# templates so that `dotnet run`
"just works" -- the package hooks the .NET CLI Run target to register a
loose-layout debug identity via the winapp CLI and launch the app via
AUMID. The same source feeds both the `dotnet new` template pack and
the VS extension VSIX, so VS-instantiated projects also pick up the
new package automatically (via the existing
`WindowsAppSDK.TemplateUtilities.NuGetPackageInstaller` wizard).
Project files (apply to both `dotnet new` and VSIX):
* SingleProjectPackagedApp/ProjectTemplate.csproj
* NavigationApp/ProjectTemplate.csproj
* MvvmApp/ProjectTemplate.csproj
* TabViewApp/ProjectTemplate.csproj
-- add `<PackageReference Include="Microsoft.Windows.SDK.BuildTools.WinApp"
Version="$WindowsSdkBuildToolsWinAppVersion$" />` inside the existing
`UseLatestWindowsAppSDK` conditional block.
`dotnet new` templating (parameter + post-action):
* Dotnet/templates/single-project/.template.config/template.json
* Dotnet/templates/navigation-app/.template.config/template.json
* Dotnet/templates/mvvm-app/.template.config/template.json
* Dotnet/templates/tabview-app/.template.config/template.json
-- add `windowsSdkBuildToolsWinAppVersion` parameter (default `0.3.1`).
-- add post-action to update the package to latest stable.
VSIX templating (`$NuGetPackages$` list consumed by the VS wizard):
* SingleProjectPackagedApp/WinUI.Desktop.Cs.*.vstemplate
* NavigationApp/WinUI.Desktop.Cs.*.vstemplate
* MvvmApp/WinUI.Desktop.Cs.*.vstemplate
* TabViewApp/WinUI.Desktop.Cs.*.vstemplate
-- append `Microsoft.Windows.SDK.BuildTools.WinApp` so the VSIX
wizard installs latest stable when the project is created.
Skipped: ClassLibrary (no app), UnitTestApp (test container), and
PackagedApp (multi-project WAP layout where `dotnet run` on the C# child
isn't packaged anyway).
Agent instructions (`dev/Templates/Dotnet/templates/single-project/`)
modernized to reflect the winappCli 0.3 surface:
* Agents.md
-- "Build, Run & Deploy" rewritten: promote `dotnet run` (auto-invokes
`winapp run` via the new NuGet) as the inner-loop default; demote
manual `Add-AppxPackage -Register` to a documented fallback.
-- Fix incorrect `winapp run` invocation (it takes the build output
*folder*, not the .exe).
-- Fix `$env:PROCESSOR_ARCHITECTURE` mapping (returns `AMD64` on x64
boxes; MSBuild needs `x64`).
-- Add a winapp CLI command cheatsheet (run, create-debug-identity,
unregister, cert generate/info, sign, pack, manifest update-assets,
manifest add-alias, tool).
-- Document MSBuild knobs: `EnableWinAppRunSupport`,
`WinAppRunUseExecutionAlias`, `WinAppRunNoLaunch`,
`WinAppLaunchArgs`.
-- Replace stale Windows AI prerequisites (LAF token,
`<WindowsAppSDKSelfContained>` overrides) with the current
package-identity / capability / hardware-gating model.
* instructions/winui-best-practices.instructions.md
-- Common-pitfalls table now recommends `winapp unregister` +
`dotnet run` (and `winapp run --clean` for first-run resets)
instead of `Add-AppxPackage -Register`.
* instructions/security.instructions.md
-- Replace bare "enable code signing" bullet with concrete
`winapp cert generate` / `cert info` / `sign` / `pack --cert`
workflow.
* instructions/testing.instructions.md
-- Drop hardcoded `-p:Platform=x64`; use the same `$Platform`
detection convention as Agents.md so tests work on ARM64
dev boxes.
dotnet rundotnet run
dotnet run|
also adding @nmetulev for review |
…t/WindowsAppSDK into user/DinahK-2SO/use_winapp
Template validation findings (TODO)
I generated and ran every template ( 🔴 Blockers1. 2. 🟡 Quality bugs3. 4. |
See #6407 for comments. We need There's a potential fix for the captionbuttons overlapping in the TabView template too. |
…gStyle in winui-dialog via a sourceName-safe placeholder.
…et to fix overlap.

Summary
dotnet runworks out of box on the WinUI templates — wire the newMicrosoft.Windows.SDK.BuildTools.WinApp 0.3.1NuGet package into the four packaged WinUI C# templates so users get
loose-layout package identity + AUMID launch out of the box.
Agents.mdand theinstructions/*.instructions.mdfiles now teach AI agents to use thepublic
winappCLI (winappCli 0.3) instead of hand-rolledAdd-AppxPackage -Register/MakeAppx/SignToolinvocations.Quick start
Extra fixes
Below are extra fixes and their manual test steps:
after fix: successful launch, no error.
(manually) add a button to demo the new dialog item
in MainPage.xaml:
in MainPage.xaml.cs:
run
after fix: successful launch, no error.
clicking the button shows the new dialog item.
after fix: item created with Generic.xaml:
Note: When running
dotnet new winui-templatedcontrol -n <item name> --project <project name>.csproj, if the Themes/Generic.xaml file already exists, the creation will be blocked with an error as below:dotnet new winui-templatedcontrol -n MyBadge2 --project test1.csprojThis issue can be resolved via flag
-I falseor--IncludeDefaultStyle false, who skips creating the Generic.xaml file. Here is an example command:The error message is generated by the dotnet template engine, it cannot be modified from the template side.
So we're adding hint to use
-I falsein comments of the generated code.winui-resw
After fix: the "Resources" string in output *.resw file won't be replaced by brutal force.
winui-tabview
Fix the caption button overlap.
After fix 5:

Before fix 5:
