VijayAnand.MauiTemplates 5.15.0

Prefix Reserved
This package has a SemVer 2.0.0 package version: 5.15.0+sha.2da44cd.
dotnet new install VijayAnand.MauiTemplates::5.15.0                
This package contains a .NET Template Package you can call from the shell/command line.

Project and Item Templates for developing .NET MAUI App that runs on Android, iOS, macOS, Windows, and Tizen

Item templates for the following:

Item Template Name
.NET MAUI Item (XAML) maui-item
.NET MAUI Item (C#) maui-item-cs
ContentPage (XAML) maui-page
ContentPage (C#) maui-page-cs
ContentPage (Razor) maui-page-razor
ContentView (XAML) maui-view
ContentView (C#) maui-view-cs
ContentView (Razor) maui-view-razor
ResourceDictionary (XAML) maui-resdict
ShellPage (XAML) maui-shell
ShellPage (C#) maui-shell-cs
ShellPage (Razor) maui-shell-razor
ContentPage (XAML) with ViewModel maui-mvvm
ContentPage (C#) with ViewModel maui-mvvm-cs
ContentPage with BlazorWebView (XAML) maui-bwv
ContentPage with BlazorWebView (C#) maui-bwv-cs
Partial Class (C#) class-cs

All of these templates currently target .NET MAUI on .NET 6/7/8 GA and its Service Releases.

Install the template package from NuGet with the below command.

Stable:

dotnet new install VijayAnand.MauiTemplates

If you've already installed this package, then this can be updated to the latest version with the below command.

dotnet new update --check-only
dotnet new update
Parameters:

Starting with v2.0.0 of the template package, to effectively support .NET MAUI on both .NET 6 and .NET 7, CLI project template defines a new parameter named framework:

And from v3.0.0 of the template package, CLI project template framework parameter adds .NET 8 as another option.

And from v4.0.0 of the template package, CLI project template defines a new parameter named language:

And from v4.4.0 of the template package, CLI project template defines a new parameter named central-pkg-mgmt:

And from v4.5.0 of the template package, CLI project template defines a new parameter named include-shared-toolkit:

And from v4.6.0 of the template package, CLI project template defines a new parameter named nightly:

And from v5.0.0 of the template package, CLI project template framework parameter adds .NET 9 as another option.

  • Nightly build: (Short notation: -ni):

    Option to reference Nightly build MAUI packages (from the CI feed) in all the supported templates.

    -ni | --nightly This is a Boolean parameter - Default value is false. Can also be used with the CPM option too.

    Note: For this work, add the following URL as a NuGet package source and more details here:

    https://aka.ms/maui-nightly/index.json

    Examples:

    dotnet new mauiapp -o MyApp -ni
    
    dotnet new mauiclasslib -o MauiLib -ni
    
    dotnet new sharedclasslib -o SharedLib -ni
    
  • Central Package Management: (Short notation: -cpm):

    This is a Boolean parameter and its default value is false. For now, this option is supported only on CLI.

    Examples:

    dotnet new mauiapp -o MyApp -cpm
    
    dotnet new mauiclasslib -o MauiLib -cpm
    
    dotnet new sharedclasslib -o SharedLib -cpm
    
  • Language: (Short notation: -lang):

    This can take C# / F# as its options (with C# being the default value, if not specified).

    Examples:

    dotnet new mauiapp -lang F# -f net7.0
    

    For creating a .NET MAUI App on .NET 8:

    dotnet new mauiapp -lang F#
    
  • Framework: (Short notation: -f)

    This can take net6.0 / net7.0 / net8.0 / net9.0 as its options (with net8.0 being the default value, if not provided).

    Examples:

    dotnet new mauiapp -f net6.0
    
    dotnet new mauiapp -f net7.0
    

    For creating a .NET MAUI App on .NET 8:

    Below command can be simplified to dotnet new mauiapp as default value of framework parameter is net8.0

    dotnet new mauiapp -f net8.0
    

    For creating a .NET MAUI App on .NET 9:

    Explicit value for the framework parameter is required.

    dotnet new mauiapp -f net9.0
    

In .NET CLI, all of these Items Template require a mandatory parameter:

  • Name: (Short notation: -n)

    The name of the Item/Page/View to create. For Pages/Views, don't need to suffix it with the name like .xaml, it will get added.

    If the name parameter is not specified, by default, the .NET CLI template engine will take the current folder name as the filename (current behaviour of the templating engine).

  • Now with more options while creating the app or class library project, ability to include NuGet packages on the fly for CommunityToolkit.Maui, CommunityToolkit.Maui.Markup, CommunityToolkit.Mvvm or all.

Note: Parameter values are case-insensitive.

Both .NET MAUI App and Class Library templates take the below optional Boolean parameters to include the officially supported CommunityToolkit NuGet packages:

Specifying the parameter name, either in short or full notation, implies that it is defined.

  • -it | --include-toolkit - Default is false
  • -im | --include-markup - Default is false
  • -imt | --include-mvvm-toolkit - Default is false

Other Parameters:

  • -ist | --include-shared-toolkit - Default is false
  • -cc | --conditional-compilation - Default is false
Conditional Compilation

And now conditional compilation can be configured so that platform source files can be defined anywhere in the project provided they follow a naming convention as mentioned below. This will allow maintaining related source files in the same place, especially MAUI Handlers.

  • *.Standard.cs - Files targeting the BCL
  • *.Android.cs - Files specific to Android
  • *.iOS.cs - Files shared with both iOS and MacCatalyst
  • *.MacCatalyst.cs - Files specific to MacCatalyst
  • *.Tizen.cs - Files specific to Tizen
  • *.Windows.cs - Files specific to Windows

For existing projects, add the below block of code in the project file (.csproj). This will modify the behavior of build process so due care must be taken if doing so.

<ItemGroup Condition="'$(TargetFramework)' != 'net8.0'">
    <Compile Remove="**\*.Standard.cs" />
    <None Include="**\*.Standard.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'ios' AND $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst'">
    <Compile Remove="**\*.iOS.cs" />
    <None Include="**\*.iOS.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
    <Compile Remove="**\iOS\**\*.cs" />
    <None Include="**\iOS\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android'">
    <Compile Remove="**\*.Android.cs" />
    <None Include="**\*.Android.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
    <Compile Remove="**\Android\**\*.cs" />
    <None Include="**\Android\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst'">
    <Compile Remove="**\*.MacCatalyst.cs" />
    <None Include="**\*.MacCatalyst.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
    <Compile Remove="**\MacCatalyst\**\*.cs" />
    <None Include="**\MacCatalyst\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'tizen'">
    <Compile Remove="**\*.Tizen.cs" />
    <None Include="**\*.Tizen.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
    <Compile Remove="**\Tizen\**\*.cs" />
    <None Include="**\Tizen\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
    <Compile Remove="**\*.Windows.cs" />
    <None Include="**\*.Windows.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
    <Compile Remove="**\Windows\**\*.cs" />
    <None Include="**\Windows\**\*.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>
All-in-One .NET MAUI App Project Template:

This takes two additional parameters to define the application design pattern and target platform respectively. Not all options are supported in the F# template. For now, only Plain and Hybrid option is available.

  • -dp | --design-pattern

Can take any one of the following values, with default value set to Plain:

Parameter Value Description
Plain App configured to work with a single, initial screen.
Hierarchical App configured to work in a Hierarchical pattern using NavigationPage.
Tab App configured to work in a Tabbed fashion using TabbedPage.
Shell App configured to work with Routes using Shell page.
Hybrid App configured to work in a Hybrid fashion using BlazorWebView.
Markup App configured to work with C# Markup syntax.
Razor App configured to work with Razor syntax.
Comet App configured to work with MVU pattern using Comet.
Reactor App configured to work with MVU pattern using Reactor.
  • -tp | --target-platform

Can take a combination of the following values, with default value set to All:

Parameter Value Description
All Targets all possible .NET MAUI supported platforms.
Base Targets base framework (.NET 6/7/8) based on the framework opted.
Android Targets Android platform.
iOS Targets iOS platform.
macOS Targets macOS platform via Mac Catalyst.
Windows Targets Windows platform.
Tizen Targets Tizen platform.
Mobile Targets Android and iOS platforms.
Desktop Targets Windows and macOS platforms.
Apple Targets iOS and macOS platforms.

Additional parameters supported:

MVVM is a delightful and development-friendly design pattern to work with. To support this, a new parameter has been introduced:

  • -mvvm | --use-mvvm - Default is false
  • -icb | --include-compiled-bindings - Default is false

Note: Opting for this MVVM option will not have any impact on the App created with Web-based Razor syntax or MVU based Comet/Reactor.

While creating a Blazor Hybrid App, an option to abstract the Razor components as a separate Razor class library.

  • -rcl | --razor-class-library - Default is false

The target for the Windows platform can be either Package (MSIX) or Unpackaged. By default, it is set as Package, this can be overridden while creating the project by including the below parameter:

  • -wu | --windows-unpackaged - Default is false

While targeting .NET 7 or later, an option to add and configure CommunityToolkit.Maui.MediaElement, Microsoft.Maui.Controls.Foldable, Microsoft.Maui.Controls.Maps, or all NuGet packages.

  • -ime | --include-media-element - Default is false
  • -if | --include-foldable - Default is false
  • -inm | --include-maps - Default is false

Note: If the project target .NET 6, selecting the MediaElement/Foldable/Maps option will NOT have any impact.

Examples:

dotnet new mauiapp --design-pattern Hybrid --target-platform Mobile
dotnet new mauiapp -dp Shell -tp Android
.NET MAUI Class Library Project Template:

Similar to All-in-One .NET MAUI App, the Class Library project template also takes target-platform as a parameter that takes a combination from the same set of values (with All being the default value).

  • Can be created targeting .NET Razor SDK
    • Parameter name: --use-razor-sdk | -usr
  • Can be created targeting .NET MAUI Core
    • Parameter name: --use-maui-core | -umc
  • Can be created targeting .NET MAUI Essentials
    • Parameter name: --use-maui-essentials | -ume
Shared Class Library Project Template:

The Target Framework of Xamarin.Forms library can be defined with the the below parameter.

  • -xf | --xamarin-forms

Supported values are:

  • netstandard2.0 (Default, if not specified)
  • netstandard2.1

Define the Target Framework of .NET MAUI library with the -f | --framework parameter.

This takes the below optional Boolean parameters to include the officially supported NuGet packages:

Specifying the parameter name, either in short or full notation, implies that it is defined.

Single parameter to include all the supported NuGet packages:

  • -asp | --all-supported-packages - Default is false

Specific to Xamarin.Forms:

  • -ife | --include-forms-essentials - Default is false
  • -ift | --include-forms-toolkit - Default is false
  • -ifm | --include-forms-markup - Default is false

Specific to .NET MAUI:

  • -imt | --include-maui-toolkit - Default is false
  • -imm | --include-maui-markup - Default is false

Common to both:

  • -inmt | --include-mvvm-toolkit - Default is false

For more details: run this command in the terminal (use -h to save some keystrokes):

dotnet new mauiapp --help
dotnet new mauiclasslib --help
dotnet new sharedclasslib --help
Partial Class Item Template:

This item template (short name: class-cs) allows to create a C# class from CLI with support for multiple options.

Parameter Name Type Default Value Remarks
access-modifier choice public Specifies the accessibility of the class type.
base text object Specifies the base type for the class.
abstract bool false Option to create the type as abstract.
partial bool true Option to create the type as partial.
sealed bool false Option to create the type as sealed.
static bool false Option to create the type as static.

Access Modifier parameter (--access-modifier | -am):

Supported values are:

  • public (default value, if not provided)
  • internal
  • protected
  • private

File-scoped Namespace parameter (-fsn | --file-scoped-namespace), the default value is false.

Usage:

After installation, use the below command(s) to create new artifacts using the template (both provide the same output):

With parameter names abbreviated:

.NET MAUI App:

dotnet new mauiapp -n MyApp -dp Shell
dotnet new mauiapp -n MyApp -dp Hybrid
dotnet new mauiapp -n MyApp -dp Markup
dotnet new mauiapp -n MyApp -dp Razor
dotnet new mauiapp -n MyApp -dp Comet
dotnet new mauiapp -n MyApp -dp Reactor

Option to use MVVM:

dotnet new mauiapp -n MyApp -mvvm
dotnet new mauiapp -n MyApp -dp Markup -mvvm

Option to use MVVM (Compiled Bindings):

dotnet new mauiapp -n MyApp -mvvm -icb

Option to create Razor class library while creating Blazor Hybrid App:

dotnet new mauiapp -n MyApp -dp Hybrid -rcl

Option to include NuGet packages:

dotnet new mauiapp -n MyApp -dp Shell -it -im -imt -ime -inm -if

Option to configure conditional compilation:

dotnet new mauiapp -n MyApp -dp Shell -cc

.NET MAUI Class Library:

dotnet new mauiclasslib -n MyApp.Core

Option to include NuGet packages:

dotnet new mauiclasslib -n MyApp.Core -it -im -imt

Option to configure conditional compilation:

dotnet new mauiclasslib -n MyApp.Core -cc

Shared Class Library:

dotnet new sharedclasslib -n MyApp.UI

Option to include all supported NuGet packages:

dotnet new sharedclasslib -n MyApp.UI -asp
Generic Item Template:
  • A revolutionary generic template, in XAML and C#, for creating items of any type
  • And it is named as: maui-item and maui-item-cs
  • Both needs one required parameter, -b / --base, the base type
  • And optionally takes another parameter, -g / --generic, to specify the generic base type
  • In addition, XAML template takes one more parameter, -xo / --xaml-only, to generate only XAML definition

Note: Namespace resolution in both XAML and C# file is left to the user as deriving them with the template is outside its scope.

dotnet new maui-item -n LoginPage -b ContentPage
dotnet new maui-item-cs -n ProductView -b ContentView
dotnet new maui-item -n CartPage -b MauiPage -g CartViewModel

For Page/Shell/View Item templates, don't suffix anything to the name, it'll be included automatically.

Pages:

dotnet new maui-page -n Home
dotnet new maui-page-cs -n Home
dotnet new maui-page-razor -n Home
Page with ViewModel:
dotnet new maui-mvvm -n Login
dotnet new maui-mvvm-cs -n Login

ContentPage with BlazorWebView:

dotnet new maui-bwv -n Home
dotnet new maui-bwv-cs -n Home

Views:

dotnet new maui-view -n Order
dotnet new maui-view-cs -n Order
dotnet new maui-view-razor -n Order

Shell:

dotnet new maui-shell -n App
dotnet new maui-shell-cs -n App
dotnet new maui-shell-razor -n App

Resource Dictionary:

dotnet new maui-resdict -n DarkTheme
dotnet new maui-resdict -n LightTheme -xo

Partial Class:

dotnet new class-cs -n BaseViewModel -b ObservableObject
dotnet new class-cs -n OrderDataStore -b IDataStore -p false -am internal

With parameter names expanded:

.NET MAUI App:

dotnet new mauiapp --name MyApp --design-pattern Shell
dotnet new mauiapp --name MyApp --design-pattern Hybrid
dotnet new mauiapp --name MyApp --design-pattern Markup
dotnet new mauiapp --name MyApp --design-pattern Razor
dotnet new mauiapp --name MyApp --design-pattern Comet
dotnet new mauiapp --name MyApp --design-pattern Reactor

Option to use MVVM:

dotnet new mauiapp --name MyApp --use-mvvm
dotnet new mauiapp --name MyApp --design-pattern Markup --use-mvvm

Option to use MVVM (Compiled Bindings):

dotnet new mauiapp --name MyApp --use-mvvm --include-compiled-bindings

Option to create Razor class library while creating Blazor Hybrid App:

dotnet new mauiapp --name MyApp --design-pattern Hybrid --razor-class-library

Option to include NuGet packages:

dotnet new mauiapp --name MyApp --design-pattern Shell --include-toolkit --include-markup --include-mvvm-toolkit --include-media-element --include-maps --include-foldable
dotnet new mauiapp --name MyApp --design-pattern Shell --conditional-compilation

.NET MAUI Class Library:

dotnet new mauiclasslib --name MyApp.Core
dotnet new mauiclasslib --name MyApp.Core --include-toolkit --include-markup --include-mvvm-toolkit
dotnet new mauiclasslib --name MyApp.Core --conditional-compilation

Shared Class Library:

dotnet new sharedclasslib --name MyApp.UI
dotnet new sharedclasslib --name MyApp.UI --all-supported-packages
Generic Item Template:
dotnet new maui-item --name LoginPage --base ContentPage
dotnet new maui-item-cs --name ProductView --base ContentView
dotnet new maui-item --name CartPage --base MauiPage --generic CartViewModel

For Page/Shell/View Item templates, don't suffix anything to the name, it'll be included automatically.

Pages:

dotnet new maui-page --name Home
dotnet new maui-page-cs --name Home
dotnet new maui-page-razor --name Home
Page with ViewModel:
dotnet new maui-mvvm --name Login
dotnet new maui-mvvm-cs --name Login

ContentPage with BlazorWebView:

dotnet new maui-bwv --name Home
dotnet new maui-bwv-cs --name Home

Views:

dotnet new maui-view --name Order
dotnet new maui-view-cs --name Order
dotnet new maui-view-razor --name Order

Shell:

dotnet new maui-shell --name App
dotnet new maui-shell-cs --name App
dotnet new maui-shell-razor --name App

Resource Dictionary:

dotnet new maui-resdict --name DarkTheme
dotnet new maui-resdict --name LightTheme --xaml-only

Partial Class:

dotnet new class-cs --name BaseViewModel
dotnet new class-cs --name OrderDataStore --base IDataStore --partial false --access-modifier internal
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.15.0 85 10/23/2024
5.14.0 68 10/10/2024
5.13.0 115 9/13/2024
5.12.1 104 8/15/2024
5.12.0 62 8/14/2024
5.11.0 56 8/5/2024
5.10.1 45 8/1/2024
5.10.0 64 7/26/2024
5.9.0 87 7/9/2024
5.8.0 61 7/5/2024
5.7.0 65 6/28/2024
5.6.2 78 6/13/2024
5.6.1 50 6/12/2024
5.6.0 51 6/11/2024
5.5.0 66 6/6/2024
5.4.0 233 5/22/2024
5.3.0 252 5/14/2024
5.2.1 130 4/17/2024
5.2.0 79 4/10/2024
5.1.0 399 3/12/2024
5.0.1 729 2/18/2024
5.0.0 185 2/14/2024
4.9.0 216 2/8/2024
4.8.1 605 1/18/2024
4.8.0 150 1/15/2024
4.7.0 369 1/4/2024
4.6.0 1,059 11/30/2023
4.5.0 232 11/24/2023
4.4.0 359 11/14/2023
4.4.0-preview.5 180 11/10/2023
4.4.0-preview.4 99 11/9/2023
4.4.0-preview.3 305 10/30/2023
4.4.0-preview.2 374 10/18/2023
4.4.0-preview.1 103 10/18/2023
4.3.0 285 10/13/2023
4.2.2 248 10/7/2023
4.2.1 178 10/4/2023
4.2.0 116 10/4/2023
4.1.1 142 9/26/2023
4.1.0 169 9/13/2023
4.0.1 166 8/27/2023
4.0.0 137 8/17/2023
3.6.0 142 8/10/2023
3.5.0 177 7/14/2023
3.4.1 189 6/14/2023
3.4.0 119 6/13/2023
3.3.2 168 5/18/2023
3.3.1 116 5/17/2023
3.3.0 122 5/16/2023
3.2.4 191 4/20/2023
3.2.3 141 4/17/2023
3.2.2 131 4/14/2023
3.2.1 132 4/11/2023
3.2.0 133 4/5/2023
3.2.0-preview.6 117 4/3/2023
3.2.0-preview.5 115 4/2/2023
3.2.0-preview.4 114 3/30/2023
3.2.0-preview.3 120 3/27/2023
3.2.0-preview.2 119 3/25/2023
3.2.0-preview.1 114 3/24/2023
3.1.0 177 3/23/2023
3.1.0-preview.9 113 3/20/2023
3.1.0-preview.8 120 3/18/2023
3.1.0-preview.7 117 3/15/2023
3.1.0-preview.6 112 3/14/2023
3.1.0-preview.5 116 3/11/2023
3.1.0-preview.4 111 3/9/2023
3.1.0-preview.3 119 3/7/2023
3.1.0-preview.2 115 3/4/2023
3.1.0-preview.1 116 3/3/2023
3.0.2 199 3/6/2023
3.0.1 140 3/3/2023
3.0.0 163 2/22/2023
2.4.1 148 2/17/2023
2.4.0 161 2/6/2023
2.3.1 183 1/27/2023
2.3.0 155 1/25/2023
2.2.0 185 12/19/2022
2.1.3 1,166 11/23/2022
2.1.2 366 11/18/2022
2.1.1 336 11/10/2022
2.1.0 329 11/8/2022
2.0.3 397 10/26/2022
2.0.2 396 10/25/2022
2.0.1 438 10/21/2022
2.0.0 461 10/4/2022
1.7.3 581 8/5/2022
1.7.2 614 6/17/2022
1.7.1 478 6/7/2022
1.7.0 516 5/24/2022
1.6.0 462 5/23/2022
1.5.0 519 5/12/2022
1.4.1 562 4/28/2022
1.4.0 455 4/27/2022
1.3.1 512 4/19/2022
1.3.0 503 4/14/2022
1.2.0 520 3/29/2022
1.1.3 582 2/19/2022
1.1.2 452 2/18/2022
1.1.1 465 2/16/2022
1.1.0 432 2/16/2022
1.0.8 454 2/14/2022
1.0.7 444 2/14/2022
1.0.6 466 2/1/2022
1.0.5 446 1/31/2022
1.0.4 391 11/9/2021
1.0.3 404 10/15/2021
1.0.2 1,001 8/16/2021
1.0.1 433 8/13/2021
1.0.0 371 8/12/2021

Join me on Developer Thoughts (https://egvijayanand.in/), an exclusive blog for articles on Xamarin.Forms, .NET MAUI and Blazor.

This template package does not gather any usage or telemetry data, even anonymously, ensuring that you can use it freely and with complete privacy assurance.

What's new in ver. 5.15.0:
--------------------------
Introduced the option to add and configure the Syncfusion.Maui.Toolkit NuGet package.

Note: This would be an explicit option.

-isft | --include-syncfusion-toolkit - Default value is false

dotnet new mauiapp -o MyApp -isft

dotnet new mauiclasslib -o MauiLib -isft

dotnet new sharedclasslib -o SharedLib -isft

v5.14.0:

Templates updated to support .NET MAUI 9 RC2 release (v9.0.0-rc.2.24503.2).

v5.13.0:

Templates updated to support .NET MAUI 9 RC1 release (v9.0.0-rc.1.24453.9).

The WindowsSdkPackageVersion property has been temporarily included to make use of the latest version of the MVVM toolkit.

v5.12.1:

Android targetSdkVersion bumped to v35 for App projects targeting .NET 9

v5.12.0:

Templates updated to support .NET MAUI 9 Preview 7 release (v9.0.0-preview.7.24407.4).

With the MainPage property of the Application made obsolete from this release, the corresponding changes have been implemented in the CreateWindow override method.

v5.11.0:

1. Introduced an option to support the XML-based solution file (slnx) format.

This would be an explicit option since the SLNX feature is currently in the preview stage and is only supported on VS2022.

-slnx | --use-slnx - Default value is false

dotnet new mauiapp -o MyApp -slnx

2. Defined an item template to generate the slnx solution file from the CLI.

dotnet new slnx

v5.10.1:

The value of MauiVersion property has been updated to version 8.0.71 to represent the most recent minor service release, .NET MAUI 8 SR7.1.

A minor defect has been fixed in the .NET MAUI Class Library project template.

v5.10.0:

The reference to the Microsoft.Maui.Controls.Compatibility NuGet package has been removed from the .NET 9 project templates.

Reliability improvements.

v5.9.0:

Templates updated for .NET MAUI 9 Preview 6 (v9.0.0-preview.6.24327.7) and .NET MAUI 8 SR7 release (v8.0.70).

v5.8.0:

Introduced the option to add and configure the CommunityToolkit.Maui.Camera package in both the MAUI App and Class Library project templates.

v5.7.0:

Introduced an option to add the Maps package in both MAUI and Shared Class Library project templates.

Added Apple's Privacy Manifest file to facilitate submitting macOS app (MacCatalyst) to the App Store.

Little housekeeping to make the templates even more reliable.

v5.6.2:

When not using the NuGet CPM feature, defined the value for the Maui Version property as a floating version.

This is done only for the .NET 8 Stable channel.

v5.6.1:

Templates updated to support .NET MAUI 8 SR6 release (v8.0.60).

v5.6.0:

Introduced using the NuGet CPM feature from within Visual Studio IDE.

Automated the process of using MAUI Nightly builds without any need for manual configuration with a local NuGet.config file.

Just opt in for Nightly build and you're ready to go.

While using the mcl option, Directory.Packages.props file would get listed as a solution item to update the MauiVersion property, if necessary.

Templates updated for .NET 9 Preview 5.

v5.5.0:

Introduced an option to abstract the Shared components as a separate .NET MAUI Class Library

This will create a solution structure that is akin to Xamarin.Forms (the only difference is that there won't be multiple head projects)

-mcl | --maui-class-library - Default value is false

dotnet new mauiapp -o MyApp -mcl

v5.4.0:

Templates updated to support .NET MAUI 9 Preview 4 release (9.0.0-preview.4.10690).

Added Apple's Privacy Manifest file to facilitate submitting iOS app to the store.

v5.3.0:

Templates updated to support latest .NET MAUI 8 service release (SR5 - 8.0.40).

v5.2.1:

Templates updated to support .NET 9 Preview 3.

v5.2.0:

Templates updated to support the latest .NET MAUI service release.

The .NET MAUI Community Toolkit package version bumped to reference the latest release.

v5.1.0:

Templates updated for latest .NET MAUI release.

The MauiVersion property is updated to dynamically refer to the latest available service release (8.*).

While using the CPM feature, this refers to the latest service release (8.0.10) as dynamic version is unsupported.

Auto inclusion of .NET MAUI Community Toolkit's xml namespace while using NET MAUI Generic item template with its type name defined with scope as mct:

dotnet new maui-item -n ThemePopup -b mct:Popup

v5.0.1:

Fixed the incorrect type name generation in the ContentPage with BlazorWebView item templates.

v5.0.0:

1. Support for creating .NET MAUI projects on .NET 9 Previews.

For this, have introduced an additional option to the framework parameter - net9.0

Note: The default value for the framework parameter remains as net8.0, which means to create a project for .NET 9, an explicit value of net9.0 is to be passed.

dotnet new mauiapp -o MyApp -f net9.0

2. On the stable channel, the value of the MauiVersion property is bumped to 8.0.7 to support the latest version of .NET MAUI 8 NuGet packages.

v4.9.0:

1. Better namespace resolution for item templates (support for first level folder)

2. Script automation for item templates

For more details, check this article:

https://egvijayanand.in/dotnet-maui-item-templates-made-easy-on-cli-and-visual-studio-code/

v4.8.1:

Defined MauiVersion property (with its value set to 8.0.6) in the .NET 8 stable template to support .NET MAUI 8 SR1

For more details, check this article:

https://egvijayanand.in/dotnet-maui-8-service-release-1/

v4.8.0:

1. Auto Suffix for the files created with the Page, Shell and View item templates (both XAML and C#).

dotnet new maui-page -n Settings

Output: SettingsPage.xaml and SettingsPage.xaml.cs

dotnet new maui-view-cs -n Order

Output: OrderView.cs

2. A revolutionary generic template, in XAML and C#, for creating items of any type.

And it is named as: maui-item and maui-item-cs

Both need one required parameter, -b / --base, the base type.

Optionally takes another parameter, -g / --generic, to specify the generic base type.

In addition, the XAML template takes one more parameter, -xo / --xaml-only, when defined, generates only XAML definition.

Note: Namespace resolution in both XAML and C# file is left to the user as deriving them with the template is outside its scope.

Example:

dotnet new maui-item -n HomePage -b ContentPage

Output: HomePage.xaml and HomePage.xaml.cs

public partial class HomePage : ContentPage {}

dotnet new maui-item -n SearchPage -b MauiPage -g SearchViewModel

Output: SearchPage.xaml and SearchPage.xaml.cs

public partial class SearchPage : MauiPage<SearchViewModel> {}

v4.7.0:

Auto-binding the project's RootNamespace as the namespace for newly created source files from item templates (Supported only on .NET 7 SDK or later).

Xamarin.Forms Target Framework selection in Shared Class Library project template.

Parameter name: -xf | --xamarin-forms

Supported values are netstandard2.0 (default value, if not specified) and netstandard2.1

Usage:

dotnet new sharedclasslib -o SharedLib (Defaults to netstandard2.0 for Xamarin.Forms and net8.0 for .NET MAUI)

dotnet new sharedclasslib -o SharedLib -xf netstandard2.1 -f net7.0

v4.6.0:

Option to reference Nightly build MAUI packages (from CI feed) in all of the supported templates.

-ni | --nightly (Boolean parameter - Default value is false. Can also be used with the CPM option too).

dotnet new mauiapp -o MyApp -ni

dotnet new mauiclasslib -o MauiLib -ni

dotnet new sharedclasslib -o SharedLib -ni

Note: For this work, add the following URL as a NuGet package source:

https://aka.ms/maui-nightly/index.json

v4.5.0

.NET MAUI Community Toolkit package versions bumped to their latest versions supporting the .NET 8 release.

Option to reference Shared Toolkit NuGet package in all of the templates.

--include-shared-toolkit | -ist (Boolean parameter - Default value is false.)

dotnet new mauiapp -o MyApp -ist

dotnet new mauiclasslib -o MauiLib -ist

v4.4.0:

Templates updated for .NET 8 RTM.

All preview features are now stable.

Note: For now, CPM feature is only supported on CLI.

v4.4.0-preview.5:

Another set of .NET 8 / C# 12 features (Primary Constructors).

v4.4.0-preview.4:

.NET MAUI Version on the Main page of the App.

Another set of .NET 8 / C# 12 features.

v4.4.0-preview.3:

Started incorporating .NET 8 / C# 12 features wherever possible.

v4.4.0-preview.2:

Support for the CPM option extended to Class Library projects as well.

dotnet new mauiclasslib -o MauiLib -cpm

dotnet new sharedclasslib -o SharedLib -cpm

v4.4.0-preview.1:

Introduced an option for NuGet Central Package Management in CLI project templates.

-cpm | --central-pkg-mgmt - The default value is false.

dotnet new mauiapp -o MyApp -cpm

v4.3.0

Templates updated for .NET 8 RC2.

v4.2.2:

Reliability enhancement.

v4.2.1:

Defect fix in solution file.

v4.2.0:

Support for Blazor Hybrid in F# project template. Added the design-pattern parameter for this.

This takes two options, Plain and Hybrid. The default value being Plain.

Note: RCL project in the F# template is C# based as Razor compilation is not working on F# as expected.

The first command creates a Plain app whereas the second one creates a Hybrid app.

dotnet new mauiapp -o MyApp -lang F#

dotnet new mauiapp -o HybridApp -dp Hybrid -lang F#

To create project targeting .NET 7, include the Framework parameter -f net7.0

Option for file-scoped namespace in Partial Class C# template.

Option to include reference Shared Toolkit while creating the Shared Class Library project.

.NET MAUI Community Toolkit package versions bumped to their latest versions.

v4.1.1:

Updated the .NET MAUI Class Library project file.

v4.1.0:

Templates updated for .NET 8 RC1.

Project file enhancements.

The default value for Framework parameter (--framework / -f) is now updated as net8.0

v4.0.1:

Bug fix in F# template.

v4.0.0:

.NET MAUI App F# project template with Fabulous.

Note: Default language in CLI is C#. Since not all options in C# is supported in F#, refer to Help for more details.

dotnet new mauiapp -h -lang F#

Project targeting .NET 7 (default version):

dotnet new mauiapp -o MyApp -lang F#

Project targeting .NET 8:

dotnet new mauiapp -o MyApp -f net8.0 -lang F#

v3.6.0:

Templates updated for .NET 8 Preview 7.

For broader template usage, the .NET MAUI package references are updated to use the $(MauiVersion) variable rather than a fixed version.

First community contribution from @adospace (for Reactor template changes).

v3.5.0:

Templates updated for .NET 8 Preview 6.

CommunityToolkit.Maui.Maps for the Windows platform now work on .NET 8 as well.

Opting for this will include the NuGet package and configure it in the .NET MAUI startup in MauiProgram.cs

v3.4.1:

Added support for the newly released CommunityToolkit.Maui.Maps NuGet package to support the Maps feature on the Windows platform.

Opting for this will include the NuGet package and configure it in the .NET MAUI startup in MauiProgram.cs

Update your "Bing Maps API Key" for it to work properly, visit https://www.bingmapsportal.com/ to generate one.

Note: For now, this is supported only on .NET 7. Support for .NET 8 Preview in a future release.

dotnet new mauiapp -o MyApp -inm

(or)

dotnet new mauiapp -o MyApp --include-maps

v3.4.0:

Templates updated for .NET 8 Preview 5.

Version # bumped to the latest stable for CommunityToolkit.Maui (v5.2.*), CommunityToolkit.Maui.Markup (v3.2.*), and CommunityToolkit.Maui.MediaElement (2.0.*) NuGet packages.

v3.3.2:

Made changes in the source files of Hybrid and Reactor project templates.

v3.3.1:

For library projects on .NET 8, explicit package references for Microsoft.Maui.* NuGet packages.

v3.3.0:

Templates updated for .NET 8 Preview 4.

On .NET 8, explicit package references for Microsoft.Maui.Controls and Microsoft.Maui.Controls.Compatibility NuGet packages.

Version # bumped to the latest stable for CommunityToolkit.Maui (v5.1.0) and CommunityToolkit.Mvvm (v8.2.0) NuGet packages.

v3.2.4:

Fixed the issue of _Imports.razor file getting excluded while creating a project in the Razor design pattern.

v3.2.3:

Platforms folder filtered out based on the target platform opted-in for .NET MAUI App and Class Library project.

v3.2.2:

Conditionally defined supported platforms properties based on the target platform opted-in for .NET MAUI Class Library as well.

v3.2.1:

Templates updated for .NET 8 Preview 3.

v3.2.0:

All the preview features have reached stable.

v3.2.0-preview.6:

With support for StartPath property while creating the BlazorWebView item templates on .NET 8.

Note: Restore the project before making use of the item template.

v3.2.0-preview.5:

An item template for BlazorWebView in XAML and C#.

Note: While working with .NET 7 or higher SDK, the namespace parameter in short notation needs to be passed as -p:na (i.e., it needs to be prefixed with -p:).

dotnet new maui-bwv -n HomePage -na MyApp.Views

dotnet new maui-bwv-cs -n HomePage -na MyApp.Views

On .NET 7 or later:

dotnet new maui-bwv -n HomePage -p:na MyApp.Views

dotnet new maui-bwv-cs -n HomePage -p:na MyApp.Views

v3.2.0-preview.4:

Conditionally defined supported platforms properties based on the target platform opted-in.

v3.2.0-preview.3:

1. While targeting .NET 8, the StartPath property is set to load a Razor component other than the one defined with the default route address of '/'

2. A change in the navigation menu style for better interop

v3.2.0-preview.2:

1. Fixed the issue #124 - The project node is not closed properly in the solution file while creating a Blazor Hybrid with the RCL option from CLI.

2. Stability improvements that extend the list of copy-only binary files.

v3.2.0-preview.1:

While creating a Blazor Hybrid App, an option to abstract the Razor components as a separate Razor class library.

-rcl | --razor-class-library - Default value is false

dotnet new mauiapp -n MyApp -dp Hybrid -rcl
(or)
dotnet new mauiapp --name MyApp --design-pattern Hybrid --razor-class-library

v3.1.0:

All the preview features have reached stable.

v3.1.0-preview.9:

1. Introduced an item template to generate Page and its ViewModel in a single command, available for both XAML and C#.

The Page will be generated in the Views folder and ViewModel will be generated in the ViewModels folder.

Can also be overridden to generate in the same folder with the -sf | --same-folder option.

The ViewModels are generated with the base class titled BaseViewModel (implementation left to the user).

Recommended to add CommunityToolkit.Mvvm, an officially supported NuGet package, to make it easy to work with MVVM design pattern.

Since it makes use of the .NET 7 SDK feature of auto namespace resolution, so restore the project before executing the commands.

Note: Don't suffix anything to the name, it'll be included automatically.

dotnet new maui-mvvm -n Login

dotnet new maui-mvvm-cs -n Login

Output structure:

XAML:

ViewModels
   LoginViewModel.cs
Views
   LoginPage.xaml
   LoginPage.xaml.cs

C#:

ViewModels
   LoginViewModel.cs
Views
   LoginPage.cs

v3.1.0-preview.8:

1. Added the option to use Compiled Bindings option while using the MVVM option. This will make use of the x:Bind extension instead of the Binding extension.

-icb | --include-compiled-bindings - Default value is false.

dotnet new mauiapp -n MyApp -mvvm -icb

Note: When the MVVM option is not opted-in, selecting this compiled binding option will include only the NuGet package reference.

v3.1.0-preview.7:

1. Added the option to create a .NET MAUI App with the MVU pattern using Reactor.

To facilitate this, the design-pattern parameter now takes the option of Reactor.

dotnet new mauiapp -o MyApp -dp Reactor

Note: MVVM option won't have any impact on the App created with Reactor option as it is based on the MVU design pattern.

v3.1.0-preview.6:

1. Now MVVM option works with an App created with a Hybrid design pattern also.

dotnet new mauiapp -o MyApp -dp Hybrid -mvvm

2. Added the option to create a .NET MAUI App with the MVU pattern using Comet.

To facilitate this, the design-pattern parameter now takes the option of Comet.

dotnet new mauiapp -o MyApp -dp Comet

Since this Comet is still in the PoC stage and no published roadmap for future updates. So, try it at your own risk.

Note: MVVM option won't have any impact on the App created with Comet option as it is based on the MVU design pattern.

v3.1.0-preview.5:

1. MVVM is a delightful and development-friendly design pattern to work with. To support this, a new parameter has been introduced:

-mvvm | --use-mvvm and its default value is false.

XAML with MVVM:

dotnet new mauiapp -o MyApp -mvvm

C# Markup with MVVM:

dotnet new mauiapp -o MyApp -dp Markup -mvvm

To work with .NET 8 Previews: specify the framework parameter and its value: -f net8.0

Note: Opting for this MVVM option will not have any impact on the Web-based AppModels such as Blazor syntax (Hybrid) / Razor syntax.

v3.1.0-preview.4:

1. Added the option to create a .NET MAUI App using C# Markup syntax with CommunityToolkit.Maui.Markup NuGet package.

To facilitate this, the design-pattern parameter now takes the option of Markup.

dotnet new mauiapp -o MarkupApp -dp Markup

dotnet new mauiapp -o MarkupApp -f net8.0 -dp Markup

v3.1.0-preview.3:

1. Fixed the build issue (#109) of the .NET MAUI class library with .NET MAUI Essentials targeting the Windows platform.

2. Added the option to create a .NET MAUI App using Razor syntax with BlazorBindings.Maui NuGet package.

To facilitate this, the design-pattern parameter now takes the option of Razor.

dotnet new mauiapp -o BlazorBindings -dp Razor

dotnet new mauiapp -o BlazorBindings -f net8.0 -dp Razor

3. Item templates for .NET MAUI ContentPage, ContentView, and ShellPage using Razor syntax.

dotnet new maui-page-razor -n SearchPage

dotnet new maui-view-razor -n OrderView

dotnet new maui-shell-razor -n AppShell

4. Ability to set the access modifier (--access-modifier | --am) while creating a C# class from CLI.

The default value is public.

dotnet new class-cs -n Routes -am internal

v3.1.0-preview.2:

1. .NET MAUI App and Library project framework targets were restructured to better align with the development/build platforms.

This enables to make use of the template without any modification across OS such as Windows, macOS, and Linux.

2. .NET MAUI Class Library can be created target .NET MAUI Essentials.

Parameter name: --use-maui-essentials | -ume

3. While targeting .NET 8 Preview, the Tizen platform target is commented out in the project file as a public preview of the Tizen workload is yet to be made available.

This will be re-enabled once the workload is made available.

Examples:

With default values, below command creates a library project for .NET 7 with Target Platform set to All.

dotnet new mauiclasslib -o MyLib -ume

Below command creates a library project for .NET 8 with Target Platform set to Mobile (iOS and Android) and .NET 8 (Base framework).

dotnet new mauiclasslib -f net8.0 -o MyLib -ume -tp Mobile Base

v3.1.0-preview.1:

1. Similar to the All-in-One .NET MAUI App, the Class Library project template also takes target-platform as a parameter that takes a combination of the following values (with All being the default value).

All      Targets all possible .NET MAUI-supported platforms.
Base     Targets base framework (.NET 6/7/8) based on the framework selected.
Android  Targets Android platform.
iOS      Targets iOS platform.
macOS    Targets macOS platform via Mac Catalyst.
Windows  Targets Windows platform via WinUI 3.
Tizen    Targets Tizen platform.
Mobile   Targets Android and iOS platforms.
Desktop  Targets Windows and macOS platforms.
Apple    Targets iOS and macOS platforms.

2. .NET MAUI Class Library can be created target .NET Razor SDK.

Parameter name: --use-razor-sdk | -usr

3. .NET MAUI Class Library can be created target .NET MAUI Core.

Parameter name: --use-maui-core | -umc

Note: .NET MAUI Essentials is a transitive dependency to .NET MAUI Core.

Examples:

With default values, below command creates a library project for .NET 7 with Target Platform set to All.

dotnet new mauiclasslib -o MyLib -urs -umc

Below command creates a library project for .NET 8 with Target Platform set to Mobile (iOS and Android) and .NET 8 (Base framework).

dotnet new mauiclasslib -f net8.0 -o MyLib -urs -umc -tp Mobile Base

v3.0.2:

Fix for https://github.com/egvijayanand/dotnet-maui-templates/issues/110

v3.0.1:

1. Additional parameters added to the Partial Class (class-cs) item template.

Name        Type    Default Value   Remarks
--------------------------------------------------------------------------
base        text    object          Specifies the base type for the class.
abstract    bool    false           Option to create the type as abstract.
partial     bool    true            Option to create the type as partial.
sealed      bool    false           Option to create the type as sealed.
static      bool    false           Option to create the type as static.

Examples:

dotnet new class-cs -n BaseViewModel -b ObservableObject

Opting out of partial feature:

dotnet new class-cs OrderDataStore -b IDataStore -p false

2. Dependent packages have been updated to their latest versions.

v3.0.0:

Templates updated for .NET 8 Preview 1.

Supported values for target framework parameter, can be specified with --framework / -f

net6.0
net7.0 (the default value)
net8.0

Examples:

dotnet new mauiapp -f net8.0 -o MyApp

dotnet new mauiclasslib -f net8.0 -o MyLib

dotnet new sharedclasslib -f net8.0 -o MyApp.UI

v2.4.1:

1. Short name for Partial Class (C#) item template is now renamed as class-cs to avoid conflict with .NET SDK Class template (available from v7.0.200).

dotnet new class-cs -n BaseViewModel

2. While creating a .NET MAUI App, Base framework is now an option for target-platform parameter

Will be auto included when the target-platform value is set to All (the default value, if not supplied)

dotnet new mauiapp -o MyApp -tp Mobile Base

3. An item template for Shell definition in C#

dotnet new maui-shell-cs -n AppShell -p:na MyApp

v2.4.0:

1. CommunityToolkit.Maui.Markup NuGet package bumped to v3.0.0 that supports TypedBindings

2. Introduced a new item template for creating a C# class (partial) from CLI

dotnet new class -n BaseViewModel

Note:

Auto binding the project's RootNamespace as the namespace for newly created class type is supported only on .NET 7 SDK or later.

While running on earlier SDK versions, it has to be manually modified.

And due to the limitation in the templating engine, only the RootNamespace would get added, need to manually adjust for sub-folders, if any.

v2.3.1:

CommunityToolkit.Maui.MediaElement NuGet package bumped to v1.0.1 with the explicit WindowsAppSDK reference removed.

v2.3.0:

1. Ability to add reference to CommunityToolkit.Maui.MediaElement NuGet package and configure it in startup pipeline for playing audio/video in a .NET MAUI app

2. Dependent packages have been updated to reference latest stable version

CommunityToolkit.Maui - v5.0.0
CommunityToolkit.Mvvm - v8.1.0

v2.2.0:

1. Template package updated to support .NET 7 SR1 (v7.0.52).

2. Base framework is also included as a target (net6.0/net7.0) to .NET MAUI App project template when the target-platform is set to All.

3. To create a XAML-only resource dictionary template, include either --xaml-only (-xo) or --no-code-behind (-ncb) parameter.

v2.1.3:

The target-platform parameter is now updated as a multi-choice value. Can be opted-in according to the need.

And little housekeeping to improve the reliability of the templates.

v2.1.1:

1. Template package updated to support newly released .NET 7 NuGet dependencies.

2. For App project targeting .NET 7, option to add and configure Maui Foldable NuGet package.

Note: If the project target .NET 6, selecting the Foldable/Maps option will NOT have any impact.

v2.1.0:

Template package updated to support .NET 7 GA release.

v2.0.3:

1. A parameter named target-platform has been introduced that takes any one of the following values (with All being the default value).

All - Targets all possible .NET MAUI supported platforms.
Android - Targets Android platform.
iOS - Targets iOS platform.
macOS - Targets macOS platform via Mac Catalyst.
Windows - Targets Windows platform.
Tizen - Targets Tizen platform.
Mobile - Targets Android and iOS platforms.
Desktop - Targets Windows and macOS platforms.
Apple - Targets iOS and macOS platforms.

dotnet new mauiapp --target-platform Mobile

dotnet new mauiapp -tp Android

v2.0.2:

Android targetSdkVersion set in accordance with the framework version selected.

.NET 7 - targetSdkVersion 33

.NET 6 - targetSdkVersion 31

v2.0.1:

Templates have been updated to support .NET MAUI on .NET 7 (RC2 - Preview release).

v2.0.0:

1. A parameter named framework has been introduced that takes either net6.0 or net7.0 as its options (with net7.0 being the default value).

dotnet new mauiapp --framework net6.0

dotnet new mauiapp -f net7.0

2. For App project targeting .NET 7, option to add and configure Maui Maps NuGet package.

Note: If project target .NET 6, selecting the Maps option will NOT have any impact.