Repository navigation
Fix winapp new -t reactor when another template pack also registers reactor - #949
Conversation
…t name dotnet new refuses a short name that matches templates from more than one installed pack, so installing Microsoft.UI.Reactor.Templates alongside the WinUI pack broke 'winapp new -t reactor'. Parse every pack's aliases from the existing 'dotnet new uninstall' output and scaffold with the first alias no other pack registers (e.g. reactor-blank). When every alias is shared, fail early naming the conflicting pack and how to remove it. Fixes #948 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8e69318a-5a91-45e5-a82c-9c7b91487c8b
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is focused and covered by 95 passing targeted tests, a successful solution build, and NativeAOT publish.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes ambiguous Reactor template aliases by selecting a unique alias or failing with actionable guidance.
Changes:
- Detects aliases registered by other template packs.
- Scaffolds using the first unique alias.
- Adds tests and user documentation.
| File | Description |
|---|---|
WinUiTemplateCatalog.cs |
Parses installed packs and identifies shared aliases. |
NewCommand.cs |
Uses unique aliases and reports complete conflicts. |
WinUiTemplateCatalogTests.cs |
Tests pack parsing and alias selection. |
NewCommandHandlerTests.cs |
Tests successful fallback and conflict failure. |
docs/usage.md |
Documents collision handling and recovery. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 7886 passed, 37 skipped out of 7923 tests in 1118.0s (+7 tests, -141.5s vs. baseline) Test Coverage✅ 86.3% line coverage, 80.9% branch coverage · ✅ no change vs. baseline CLI Startup Time64ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 949Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 949Run Updated 2026-09-30 21:42:51 UTC · commit |
Description
If you install the standalone
Microsoft.UI.Reactor.Templatespack alongside the WinUI templates pack, both packs register the short namereactor.winapp new -t reactorpassed that name straight todotnet new. Because the name matches templates in two packs,dotnet newrefused it and scaffolding failed.winapp newnow checks which short names other installed packs also register. It creates the WinUI pack's template using the first of its aliases that no other pack claims:winapp new -t reactorscaffolds the WinUI pack's Reactor Blank App by runningdotnet new reactor-blank. The template namewinappshows and reports in--json("Template": "reactor") is unchanged.winapp newstops before asking for a project name. It exits with code 4 and prints a message that names the conflicting pack and how to remove it.winapp newstill only installs, lists and scaffolds templates from the official WinUI pack.Usage Example
This is the output observed with both packs installed (WinUI pack
0.0.7-alpha, .NET SDK 10.0.401):Before (main):
winapp new -t reactor --name BeforeFix --use-defaultsexits with code 5.After (this PR):
winapp new -t reactor --name AfterFix2 --use-defaultsexits with code 0. With--verbose, the log showsdotnet new reactor-blank, and the scaffolded app builds with 0 errors.When another pack claims every alias (
reactor,reactor-blankandwinui-reactor),winapp newexits with code 4 and creates nothing:With only the WinUI pack installed,
winapp new -t reactorstill runsdotnet new reactor, as before.Related Issue
Fixes #948
Type of Change
Checklist
Screenshots / Demo
N/A (CLI behavior; see the observed output above).
Additional Notes
winapp newalready runsdotnet new uninstallto confirm which templates the WinUI pack owns. That output lists every installed pack and its aliases, so this fix needs no extradotnetcall.Microsoft.UI.Reactor.Templatesisn't published on nuget.org. The template project that microsoft/microsoft-ui-reactor removed in Use the Windows App SDK dotnet new templates and remove our own microsoft-ui-reactor#1277 used the short namereactorapp, notreactor. The repro therefore used a local pack built to match the issue exactly: package IDMicrosoft.UI.Reactor.Templates, name "Microsoft.UI.Reactor App", short namereactor, and tagsWindows/WinUI/Desktop/Reactor. It ran in an isolatedDOTNET_CLI_HOME.dotnet new uninstalloutput, so a collision with one of them isn't detected. None of them use WinUI or Reactor short names.WinUiTemplateCatalogTestsandNewCommand*tests pass (181 passed, 1 skipped), including new handler tests for both cases above.scripts\build-cli.ps1 -SkipTests -SkipMsix -SkipNpmsucceeds, and the CLI schema is unchanged.