CLI Project and Item Templates for developing WinUI 3 based Windows Desktop Apps
Join me on Developer Thoughts, an exclusive blog for .NET MAUI and Blazor.
Package Status:
Channel | Version |
---|---|
Stable |
Item | Template Name | Type |
---|---|---|
WinUI 3 App | winui | Project |
WinUI 3 Blazor App | winui-blazor | Project |
WinUI 3 Class Library | winuilib | Project |
WinUI 3 Page | winui-page | Item |
WinUI 3 UserControl | winui-usercontrol | Item |
WinUI 3 Window | winui-window | Item |
All three project templates takes the target framework as an input parameter, can be specified with --framework
/ -f
.
And the supported values are:
- net6.0
- net7.0
- net8.0 (the default value)
All three project templates take the below optional parameter to include the officially supported CommunityToolkit.Mvvm NuGet package.
-imt
|--include-mvvm-toolkit
- Default value isfalse
Both the App project takes another optional parameter thus allowing it to be created as MVVM supported solution using the same Microsoft MVVM Toolkit.
-mvvm
|--use-mvvm
- Default value isfalse
To install the template NuGet package, use the below .NET CLI command:
Latest stable version:
dotnet new install VijayAnand.WinUITemplates
If you've already installed this package, then it can be updated to the latest version with the below command:
dotnet new update --check-only
dotnet new update
Use the below .NET CLI command to create the projects out these template:
App:
dotnet new winui -n MyApp
.NET 7 solution:
dotnet new winui -n MyApp -f net7.0
MVVM based solution:
dotnet new winui -n MyApp -mvvm
Option to include only the MVVM NuGet package:
dotnet new winui -n MyApp -imt
Blazor App:
dotnet new winui-blazor -n MyApp
.NET 7 solution:
dotnet new winui-blazor -n MyApp -f net7.0
MVVM based solution:
dotnet new winui-blazor -n MyApp -mvvm
Option to include only the MVVM NuGet package:
dotnet new winui-blazor -n MyApp -imt
Library:
dotnet new winuilib -n MyLib
.NET 7 solution:
dotnet new winuilib -n MyLib -f net7.0
Option to include only the MVVM NuGet package:
dotnet new winuilib -n MyLib -imt
Use the below .NET CLI command to create the items out these template:
All of these item templates require the name
parameter:
-n
|--name
- Name of the item
Auto suffixing of the Type name is supported for the files created with the Page and Window item templates.
Page:
dotnet new winui-page -n Order
UserControl:
dotnet new winui-usercontrol -n CardView
Window:
dotnet new winui-window -n Home