Skip to content

WinUI templates for dotnet new and VSIX#6407

Open
DinahK-2SO wants to merge 31 commits intomainfrom
user/muyuanli/dotnetnewtemplate
Open

WinUI templates for dotnet new and VSIX#6407
DinahK-2SO wants to merge 31 commits intomainfrom
user/muyuanli/dotnetnewtemplate

Conversation

@DinahK-2SO
Copy link
Copy Markdown
Contributor

@DinahK-2SO DinahK-2SO commented Apr 16, 2026

This PR adds/updates the WinUI App templates:

  1. Add WinUI templates for dotnet new
  2. Add 2 new templates for Visual Studio:
    • WinUI Navigation App
    • WinUI TabView App
  3. Add guidelines and scripts for local build
image

@DinahK-2SO DinahK-2SO marked this pull request as ready for review April 17, 2026 07:32
@DinahK-2SO DinahK-2SO changed the title User/muyuanli/dotnetnewtemplate WinUI dotnet new templates Apr 17, 2026
@DinahK-2SO DinahK-2SO changed the title WinUI dotnet new templates WinUI templates for dotnet new and VSIX Apr 17, 2026
@DinahK-2SO DinahK-2SO requested review from Scottj1s, Copilot and yeelam-gordon and removed request for yeelam-gordon April 17, 2026 19:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@DinahK-2SO DinahK-2SO force-pushed the user/muyuanli/dotnetnewtemplate branch from 75d7c86 to e3fc78f Compare April 20, 2026 03:33
MuyuanMS and others added 20 commits April 20, 2026 16:02
* Add pipelines
* Update readme
* Adding TitleBar and .ico

* Adding the ContentDialog ItemTemplate

* Adding NavigationView template

* Missed a csharp template and added

* Push

* Update WinAppSdk.CSharp.DotnetNewTemplates.csproj

* Clean up navview project

* Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/Pages/HomePage.xaml.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/Pages/AboutPage.xaml.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/Pages/SettingsPage.xaml.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/App.xaml.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update dev/VSIX/ItemTemplates/Neutral/CSharp/ContentDialog/ContentDialog.xaml.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update dev/VSIX/ProjectTemplates/Desktop/CSharp/NavigationApp/MainWindow.xaml.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add default case with exception to navigation switch statement (#6252)

* Initial plan

* Add default case throwing InvalidOperationException in navigation switch statement

Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
* Add missing item-content-dialog template for dotnet new

The csproj referenced templates/item-content-dialog/ but the directory
did not exist, which would cause dotnet pack to produce an incomplete
package. Create the template.json, dotnetcli.host.json, and the XAML
and code-behind files for a WinUI 3 ContentDialog item template.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add packaged template to NuGet template pack

The templates/packaged/ directory existed with a full template.json and
solution file but was never included in the csproj ItemGroups, so it
would not ship in the NuGet package. Add the ItemGroup that packs the
template config, solution, BlankApp, and WapProj sources.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update README with packaged and content-dialog templates

The template table was missing the wasdk-packaged and wasdk-item-dialog
entries. Add both so the README accurately documents all templates
shipped in the pack.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add language and type tags to all template.json files

Without the 'tags' property, 'dotnet new list' does not show the
language column and template discoverability is reduced. Add
tags.language=C# and tags.type (project, solution, or item) to every
template.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add postActions for automatic NuGet restore

After 'dotnet new' creates a project, the user currently has to
manually run 'dotnet restore'. Add the standard NuGet restore post-
action (actionId 210D431B) to the four project templates so packages
are restored automatically. Item templates do not need this.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add Windows-only OS constraint to all templates

WinUI 3 / Windows App SDK templates only work on Windows. Without the
constraint, 'dotnet new list' shows them on Linux and macOS where they
cannot build, leading to confusing errors. Add the os constraint so
the templates are hidden on non-Windows hosts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add description fields to template parameters

The single-project, class-library, and unit-test templates were missing
description fields on their user-facing parameters. The packaged
template already had them. Add matching descriptions so 'dotnet new
<template> --help' displays useful parameter documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add description fields to dotnetcli.host.json files

The packaged template's host file already had descriptions but the
single-project, class-library, unit-test, and item-blank-window host
files did not. Add descriptions so 'dotnet new <template> --help'
displays useful help text for every parameter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add Copyright, license acceptance, and release notes to csproj

The NuGet package was missing Copyright, PackageRequireLicenseAcceptance,
and PackageReleaseNotes metadata. Add them for completeness and better
presentation on NuGet feeds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update default dotnetVersion from net8.0 to net9.0

.NET 9.0 is the current release. Update the default TFM across all
four project templates and their dotnetcli.host.json description
examples. Users can still override with --dotnet-version net8.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use https:// for JSON schema URLs

All template.json and dotnetcli.host.json files used http:// for the
schema store URLs. Update to https:// for consistency and security.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Revert packaged template from dotnet new pack

The wasdk-packaged template uses a WAP project (.wapproj) which the
dotnet CLI does not understand, so it cannot be used with 'dotnet new'.
Remove the packaged template ItemGroup from the csproj, remove it from
the README, and restore its template.json and dotnetcli.host.json to
their pre-modification state.

This reverts the packaged-related portions of commits 31f65f2,
b8c76b7, 80c1b8f, 63d5abf, ff0bc38, 7c03a19, and 4891155.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use existing VS ContentDialog sources instead of hand-crafted copies

The ContentDialog XAML and code-behind already exist at
ItemTemplates/Neutral/CSharp/ContentDialog/. Link those files in the
csproj instead of maintaining separate copies, matching the pattern
used by the BlankWindow item template. This keeps a single source of
truth and preserves the original button click handlers.

Also update template.json sourceName and primaryOutputs to match the
original filenames (ContentDialog, not ContentDialogItem), and remove
the now-unnecessary Compile Remove directive.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Align packaged template config with other templates

The previous revert restored the packaged template.json and
dotnetcli.host.json to their original state, making them inconsistent
with the rest of the templates. Re-apply the same improvements: add
tags, constraints, postActions, update schema to https://, and default
TFM to net9.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove templates/packaged/ directory

The packaged template uses a WAP project (.wapproj) which the dotnet
CLI does not support, so it is not included in the NuGet template pack.
Remove the unused directory to avoid confusion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update default dotnetVersion from net9.0 to net10.0

.NET 10.0 is the latest officially supported version. Update the
default TFM and help text examples across all project templates.
Users can still override with --dotnet-version net8.0 or net9.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Rename template shortNames from wasdk-* to winui3-*

Use winui3- prefix instead of wasdk- since WinUI 3 is the product
name users recognize, not the shipping vehicle (Windows App SDK).

  wasdk-single        -> winui3
  wasdk-classlib      -> winui3-lib
  wasdk-unittest      -> winui3-unittest
  wasdk-item-blankwin -> winui3-window
  wasdk-item-dialog   -> winui3-dialog

Also update display names and default project names to match.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add winui3-page and winui3-usercontrol item templates

Add two new item templates that link existing VS template sources from
ItemTemplates/Neutral/CSharp/:

  winui3-page        - BlankPage (Page with XAML and code-behind)
  winui3-usercontrol - UserControl (UserControl with XAML and code-behind)

Both follow the same pattern as winui3-window and winui3-dialog: the
template.config is maintained locally while XAML/code-behind are linked
from the shared VS template sources.

Note: the dotnet new template engine does not support verifying that an
existing project exists before adding an item template. The
msbuild:RootNamespace binding will fall back to the default value if no
project is found.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add project-capability and sdk-version constraints to item templates

Item templates (window, page, usercontrol, dialog) should only appear
in 'dotnet new list' when run inside a C# project folder. Add a
'project-capability' constraint with 'CSharp' so the templates are
hidden when no C# project is found in the current directory. Also add
an sdk-version constraint requiring .NET 8.0 or later.

Inspired by https://github.com/egvijayanand/winui-templates which uses
the same approach.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Add sdk-version constraint to project templates

Require .NET 8.0 SDK or later for the three project templates
(single-project, class-library, unit-test). The templates target
net10.0-windows and will not work on older SDKs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(project): update NoWarn property to include CS2008 warning

* feat(templates): update template identities to use WinUI naming convention

* feat(templates): add symbols section to various template configurations

* feat(templates): update dotnetVersion to support .NET 8, 9, and 10 choices

* template renamings

* User/muyuanli/naming improvements (#6256)

* template renamings

* Update naming and schema

* Add back agents and instructions

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Muyuan Li (from Dev Box) <muyuanli@microsoft.com>
Co-authored-by: Muyuan Li <116717757+MuyuanMS@users.noreply.github.com>
* Enhance copilot instructions and project spec

* Fix indentation
* complete nuspec

* Update dev/VSIX/DotnetNewTemplates/WinAppSdk.CSharp.DotnetNewTemplates.csproj

Co-authored-by: Niels Laute <niels.laute@live.nl>

* Update dev/VSIX/DotnetNewTemplates/WinAppSdk.CSharp.DotnetNewTemplates.csproj

Co-authored-by: Niels Laute <niels.laute@live.nl>

* Update dev/VSIX/DotnetNewTemplates/README.md

Co-authored-by: Niels Laute <niels.laute@live.nl>

* Resolve comments

---------

Co-authored-by: Niels Laute <niels.laute@live.nl>
* Update default dotnet version to be 10.0

* Update vstemplate to be dotnet 10 as well
* set dotnet version based on installed sdk version, and increase windows sdk in tfm

* Add test script and fix existing issues with item templates

---------

Co-authored-by: Nikola Metulev <nmetulev@users.noreply.github.com>
* added frame and mainpage to main window

* winui template updates

* adding mvvm template

---------

Co-authored-by: Nikola Metulev <711864+nmetulev@users.noreply.github.com>
* Remove invalid classifications and add missing XAML

The classications now match the classifications from the VSIX templates

* Ensures IDE shows the correct field information

Also makes min version a dropdown, and sets default based on current support lifecycles / recommendations.

* Add missing min versions
)

* Updated icons

* Remove assets folder (it already pulls those from the other template)

* Layout tweaks to the navview template

* Adding a TabView template

* Update the MvvM template with counters

* Design tweaks for the TabView template

* Update icon.png
@DinahK-2SO DinahK-2SO force-pushed the user/muyuanli/dotnetnewtemplate branch from 4258460 to f619e83 Compare April 20, 2026 08:02
@DinahK-2SO
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@DinahK-2SO
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our MvvmApp Template doesn't have an icon yet.

Hi @niels9001, @nmetulev and @dotMorten , how did we create the icon for the template (like these ones for the NavigationApp)?

./dev/Templates/Source/ProjectTemplates/Desktop/CSharp/NavigationApp/WinUI.Desktop.Cs.NavigationApp.png

./dev/Templates/Source/ProjectTemplates/Desktop/CSharp/NavigationApp/WinUI.Desktop.Cs.NavigationApp.ico

Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DinahK-2SO For the MVVM one, let's use the same as the Blank app as it's currently (mostly) blank anyway :)?

(longer term, I could imagine that you decide what UI template you want, and in the next screen we could have a checkbox that says "Add MVVM"?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I didn't create those icons when I added them to the templates - I pulled it from the VSIX.

@niels9001
Copy link
Copy Markdown
Contributor

This PR adds/updates the WinUI App templates:

  1. Add WinUI templates for dotnet new

  2. Add 2 new templates for Visual Studio:

    • WinUI Navigation App
    • WinUI TabView App
  3. Add guidelines and scripts for local build

image

This is looking amazing 🚀!

Question: do we have influence on the order of the template? If so, I'd suggest the following order:

Blank app
NavigationView app
TabView app
Blank app with MVVM
Blank app with WAP
WinUI Class Library
WinUI Unit Test app


Import the VSIX Directory.Build.props for CPM and shared settings.
-->
<Import Project="$(MSBuildThisFileDirectory)..\VSIX\Directory.Build.props" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to factor shared props into a Templates\Directory.Build.props that both Dotnet and VSIX chain into

@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in slnx format now instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this project use project references to pick up template details (None elements), like the VSIX project does? This approach seems brittle, with the dotnet project needing to know details of each template.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the new item/project templates to the component/standalone VSIXes? Ideally, we'd keep these in sync.

cc: @lauren-ciha

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how we do it: We create the nuget-version of the templates, and then we just include that nuget in the VSIX installer rather than maintaining two sets of .NET templates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great approach

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to chain into this from \BuildAll.ps1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants