Categories
.NET .NET 8 .NET MAUI Android Blazor Code Desktop Developer Extensions Getting Started Hybrid iOS Mobile MVVM NuGet Templates Visual Studio What's New Windows Xamarin

What’s new in the .NET MAUI All-in-One Templates Pack

Explore the new features in detail to finish your work in a quick time.

It’s been a long time since an article describing the features of the All-in-One .NET MAUI templates pack and a lot has changed after the last article with so many new features onboarding.

As the name suggests, has a slew of features under the hood to work with .NET MAUI and is available as both a CLI Template and a VS Extension. Here’s the command to install the CLI part.

dotnet new install VijayAnand.MauiTemplates

To install as VSIX, download and install from VS Marketplace or use the Extension Manager (shortcut: Alt+X+M) from within the Visual Studio IDE, search with maui keyword with the Online Tab in focus and look for .NET MAUI Project and Item Templates.

.NET MAUI Project and Item Templates - Visual Studio Extension by Vijay Anand E G
.NET MAUI Project and Item Templates – Visual Studio Extension

The pack hosts the following:

Project Templates:

  • .NET MAUI App (C# and F#)
  • .NET MAUI Class Library
  • Shared Class Library (supports both Xamarin.Forms and .NET MAUI)

All the above templates support creating projects for Target Frameworks .NET 6, .NET 7, and .NET 8 (the default value).

On CLI, available as a parameter -f / --framework.

And within the IDE, as a drop-down list to select.

dotnet new mauiapp -o MyApp
dotnet new mauiapp -o MyApp -f net7.0

.NET MAUI App can be created with the following design patterns:

On CLI, available as a parameter -dp / --design-pattern.

And within the IDE, as a drop-down list to select.

  • Plain (Default)Available for both C# and F#
  • Hierarchical – Uses NavigationPage
  • Tab – Uses TabbedPage
  • Shell – Uses Shell
  • Hybrid – Uses BlazorWebViewAvailable for both C# and F#
  • Markup – No XAML, only C#
  • Razor – Uses BlazorBindings with Razor syntax
  • Comet – Uses the experimental MVU
  • Reactor – Uses Reactor packages
dotnet new mauiapp -o ShoppingApp -dp Shell
dotnet new mauiapp -o TravelApp -dp Hybrid
dotnet new mauiapp -o FoodOrderApp -dp Markup
dotnet new mauiapp -o RentalApp -lang F#

.NET MAUI App and Class Library can be created with the following target platforms:

On CLI, available as a parameter -tp / --target-platform. Multiple values are allowed in combination.

And within the IDE, as a multi-select drop-down list.

  • All (Default, Targets all possible .NET MAUI supported platforms and Base framework)
  • Base (Targets base framework (.NET 6/7/8), based on the framework selection)
  • 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 macOS and Windows platforms)
  • Apple (Targets iOS and macOS platforms)
dotnet new mauiapp -o MyApp -tp Android Windows

.NET MAUI Class Library can be created targeting the MAUI Core, MAUI Essentials, and MAUI Razor SDK too.

  • -umc / --use-maui-core, the default value is false
  • -ume / --use-maui-essentials, the default value is false
  • -urs / --use-razor-sdk, the default value is false
dotnet new mauiclasslib -o MauiLib
dotnet new mauiclasslib -o MauiLib -umc
dotnet new mauiclasslib -o MauiLib -ume
dotnet new mauiclasslib -o MauiLib -urs

A Shared Class Library targeting both Xamarin.Forms and .NET MAUI (discussed in detail here) can be created with the following command:

dotnet new sharedclasslib -o MyApp.UI

All 3 project templates support adding and configuring (in the App project startup) the commonly used CommunityToolkit packages.

Specific to the .NET MAUI App project:

Specific to Shared Class Library:

And option to reference VijayAnand.Toolkit.Markup (aka SharedToolkit) (This makes Bindings easy in Coded UI, check this article for more details).

dotnet new mauiapp -o MyApp -ist

Item Templates: (Ensure the project is restored before making use of the item templates)

For all the item templates, the file extension need not be included as part of the value of the name parameter -n / --name.

While working with the MVVM templates, don’t need to suffix Page/ViewModel to the name, it’ll be automatically included.

Starting with v4.8.0, the auto-type suffixing feature is now extended to Page, Shell, and View templates. An innovative generic item template has also been introduced in this version. More details here.

To check for template updates, run the below command:

dotnet new update --check-only

And to apply the update:

dotnet new update

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

  • .NET MAUI ContentPage (XAML, C#, and Razor)
    • dotnet new maui-page -n Settings
    • dotnet new maui-page-cs -n Search
    • dotnet new maui-page-razor -n Help
  • .NET MAUI ContentView (XAML, C#, and Razor)
    • dotnet new maui-view -n Order
    • dotnet new maui-view-cs -n Product
    • dotnet new maui-page-razor -n Category
  • .NET MAUI ResourceDictionary (with and without code behind)
    • dotnet new maui-resdict -n DarkTheme
    • dotnet new maui-resdict -n LightTheme -xo
  • .NET MAUI ShellPage (XAML, C#, and Razor)
    • dotnet new maui-shell -n App
    • dotnet new maui-shell-cs -n Mobile
    • dotnet new maui-shell-razor -n Desktop
  • .NET MAUI ContentPage and ViewModel (XAML and C#)
    • dotnet new maui-mvvm -n Cart
    • dotnet new maui-mvvm-cs -n Profile
  • .NET MAUI ContentPage with BlazorWebView (XAML and C#)
    • dotnet new maui-bwv -n Home
    • dotnet new maui-bwv-cs -n Search
  • Partial Class (C#)
    • dotnet new class-cs -n BaseViewModel -b ObservableObject
    • dotnet new class-cs -n ViewExtensions -st

Below are the high-level features:

  • Support for Nightly builds
    • dotnet new mauiapp -o MyApp -ni
  • Option to use NuGet Central Package Management (CPM) feature while creating a new project (only on CLI for now)
    • dotnet new mauiapp -o MyApp -cpm
  • Incorporated with .NET 8 / C# 12 features wherever possible (Primary Constructors, Collection Expression, …)
  • .NET MAUI Version on the Main page of the App
  • F# project templates (using Fabulous) supporting Plain and Hybrid design patterns. The default language on the CLI is C#, so it is necessary to add the lang parameter while creating the F# project.
    • dotnet new mauiapp -o MyApp -lang F#
    • dotnet new mauiapp -o MyApp -lang F# -dp Hybrid
  • Support to add and configure CommunityToolkit.Maui.Maps to work with the Maps feature on the Windows platform
    • dotnet new mauiapp -o MyApp -inm
  • For projects on .NET 8, explicit package references for Microsoft.Maui.* NuGet packages
  • Ability to define target platforms while creating a project
    • dotnet new mauiapp -o MobileApp -tp Android iOS
  • Ability to abstract Razor components as Razor Class Library (RCL) while creating a Hybrid project
    • dotnet new mauiapp -o HybridApp -rcl
  • On .NET 8, while creating a Hybrid project, sets the StartPath property to other than the default path
  • Support to add and configure CommunityToolkit.Maui.MediaElement to work with Audio/Video
    • dotnet new mauiapp -o MediaApp -ime
  • Support to add and configure Maui Foldable NuGet package (to work with dual screen)
    • dotnet new mauiapp -o FoldableApp -if
  • Option to use the MVVM with the CommunityToolkit.Mvvm (aka Microsoft MVVM Toolkit) NuGet package
    • dotnet new mauiapp -o MvvmApp -mvvm (Creates the whole app using MVVM)
    • dotnet new mauiapp -o MyApp -imt (Adds reference and using statements to the project)
  • Option to use the Compiled Bindings while using the MVVM. This will make use of the x:Bind extension instead of the Binding extension.
    • dotnet new mauiapp -o MvvmApp -mvvm -icb

And help is always available around the corner. Use the parameter -h / --help on CLI and as tooltips in the IDE. For example:

dotnet new mauiapp -h

To view the entire list of templates loaded in this pack, run the below command without any additional parameters. Then look for the template ID – VijayAnand.MauiTemplates

dotnet new uninstall

Further updates have been introduced in the templates pack. Please refer to this article to know more about that.

Documentation is available here. If you find any issues or features to suggest, feel free to raise an issue with appropriate details here. Ideas are most welcome.

If you find these extensions useful, kindly support the work by adding your review to the VS Marketplace and also by adding a Star to the GitHub repository where it’s actively cooked. Also, share the word with your team and inner circle.

Much of my time is spent on adding new features to the templates pack if you want to recognize the work and sustain the momentum, kindly consider sponsoring on the GitHub Sponsor page or Buy Me a Coffee page. Thanks in advance.

Happy coding. Stay connected as we continue to learn and share the experiences from this exciting journey of being a .NET developer.

By Vijay Anand E G

A software professional with over a decade long industry experience in developing products that spans across desktop, mobile, and web.

5 replies on “What’s new in the .NET MAUI All-in-One Templates Pack”

Comments are closed.