For more information about dotnet new
templates see here.
Run from a command line:
dotnet new install Avalonia.Templates
The templates should now be available in dotnet new list
:
Template Name Short Name Language Tags
----------------------------------- ------------------------- -------- -----------------------------------------
Avalonia .NET Core App avalonia.app [C#],F# Desktop/Xaml/Avalonia/Windows/Linux/macOS
Avalonia .NET Core MVVM App avalonia.mvvm [C#],F# Desktop/Xaml/Avalonia/Windows/Linux/macOS
Avalonia Cross Platform Application avalonia.xplat [C#],F# Desktop/Xaml/Avalonia/Web/Mobile
Avalonia Resource Dictionary avalonia.resource Desktop/Xaml/Avalonia/Windows/Linux/macOS
Avalonia Styles avalonia.styles Desktop/Xaml/Avalonia/Windows/Linux/macOS
Avalonia TemplatedControl avalonia.templatedcontrol [C#],F# Desktop/Xaml/Avalonia/Windows/Linux/macOS
Avalonia UserControl avalonia.usercontrol [C#],F# Desktop/Xaml/Avalonia/Windows/Linux/macOS
Avalonia Window avalonia.window [C#],F# Desktop/Xaml/Avalonia/Windows/Linux/macOS
Note:
By default dotnet CLI would create a C# template,if you want to create F# template you will need to add -lang F#
to the end of the command.
To create a new barebones application called MyApp
in its own subdirectory, run:
dotnet new avalonia.app -o MyApp
Available parameters:
-f, --framework
Description: The target framework for the project.
Options: net6.0, net7.0
By default: net6.0
-av, --avalonia-version
Description: The target version of Avalonia NuGet packages.
Options: 0.10.18, 11.0.0-preview4
By default: 0.10.18
-no-restore
Description: If specified, skips the automatic restore of the project on create.
MVVM is the recommended pattern for creating Avalonia applications. The MVVM application template uses ReactiveUI to ease building applications with complex interactions.
To create a new MVVM application called MyApp
in its own subdirectory, run:
dotnet new avalonia.mvvm -o MyApp
Available parameters:
-f, --framework
Description: The target framework for the project.
Options: net6.0, net7.0
By default: net6.0
-av, --avalonia-version
Description: The target version of Avalonia NuGet packages.
Options: 0.10.18, 11.0.0-preview4
By default: 0.10.18
-m, --mvvm
Description: MVVM toolkit to use in the template.
Options: ReactiveUI, CommunityToolkit
By default: ReactiveUI
-no-restore
Description: If specified, skips the automatic restore of the project on create.
To create a new Cross-Platform application in its own subdirectory, run:
dotnet new avalonia.xplat
Note: This type of template allows you to create an application that will work on Desktop, Browser (preview) and Mobile (iOS & Android) (preview).
To create a new Window
called MyNewWindow
, in the namespace MyApp
run:
dotnet new avalonia.window -na MyApp -n MyNewWindow
To create a new UserControl
called MyNewView
, in the namespace MyApp
run:
dotnet new avalonia.usercontrol -na MyApp -n MyNewView
To create a new Styles
list called MyStyles
, run:
dotnet new avalonia.styles -n MyStyles
To create a new ResourceDictionary
called MyResources
, run:
dotnet new avalonia.resource -n MyResources