How to list dotnet core project templates using dotnet-cli

NET core command-line interface (dotnet-cli) is a new NET Core toolset (commands) for developing NET Core Applications. The dotnet-cli toolset provides a list of pre-installed dotnet core project templates from which the user can create various NET Core Applications such as Console application, Web application, WPF (Windows Presentation Foundation) application, Windows Form application, and other test applications. The application created with dotnet-cli can be executed on any Windows, Linux, or macOS operating system.

Command to display installed dotnet core project templates

The user can use the “dotnet new –list” command to display the pre-installed dotnet core project templates, additionally, the command will also provide details like the name of the templates (template name), the short name of the template, default programming language, and the template tags.

The user can use these details to create the project of his choice from the provided template detail list. Along with the template details, the “dotnet new –list” command also displays the various options that can be used with a dotnet new command. These options can be used mostly with all the dotnet-cli commands.

Prerequisite:

The user needs to have .NET Core 1.x or above installed on his machine. The current version is 5.0 and can be downloaded here:

Command Syntax:

The syntax of the command is “dotnet new [options]“, the user can use any of the two options to execute the command yielding the same result.

  • 1. Long format: –list
  • 2. Short format: -l
Display Pre-installed NET Core project templates

Command Usage dotnet new –list:

C:\>dotnet new --list
Usage: new [options]

Options:
  -h, --help          Displays help for this command.
  -l, --list          Lists templates containing the specified name. If no name is specified, lists all templates.
  -n, --name          The name for the output being created. If no name is specified, the name of the current directory is used.
  -o, --output        Location to place the generated output.
  -i, --install       Installs a source or a template pack.
  -u, --uninstall     Uninstalls a source or a template pack.
  --type              Filters templates based on available types. Predefined values are "project", "item" or "other".
  --force             Forces content to be generated even if it would change existing files.
  -lang, --language   Specifies the language of the template to create.


Templates                                         Short Name       Language          Tags
--------------------------------------------------------------------------------------------------------
Console Application                               console          [C#], F#, VB      Common/Console
Class library                                     classlib         [C#], F#, VB      Common/Library
Unit Test Project                                 mstest           [C#], F#, VB      Test/MSTest
xUnit Test Project                                xunit            [C#], F#, VB      Test/xUnit
ASP.NET Core Empty                                web              [C#], F#          Web/Empty
ASP.NET Core Web App (Model-View-Controller)      mvc              [C#], F#          Web/MVC
ASP.NET Core Web App                              razor            [C#]              Web/MVC/Razor Pages
ASP.NET Core with Angular                         angular          [C#]              Web/MVC/SPA
ASP.NET Core with React.js                        react            [C#]              Web/MVC/SPA
ASP.NET Core with React.js and Redux              reactredux       [C#]              Web/MVC/SPA
ASP.NET Core Web API                              webapi           [C#], F#          Web/WebAPI
global.json file                                  globaljson                         Config
Nuget Config                                      nugetconfig                        Config
Web Config                                        webconfig                          Config
Solution File                                     sln                                Solution
Razor Page                                        page                               Web/ASP.NET
MVC ViewImports                                   viewimports                        Web/ASP.NET
MVC ViewStart                                     viewstart                          Web/ASP.NET

Please note the result may vary as per your installed dotnet version.

Command Template Specific Usage dotnet new <template> –list

The user can use the “dotnet new –list” command to filter the template of the same types, like for example if the user uses the following command “dotnet new “ASP” –list, the output of the command will list all the templates with the user can create web-based projects.

C:\>dotnet new ASP --list

Templates                                         Short Name      Language      Tags
---------------------------------------------------------------------------------------------------
ASP.NET Core Empty                                web             [C#], F#      Web/Empty
ASP.NET Core Web App (Model-View-Controller)      mvc             [C#], F#      Web/MVC
ASP.NET Core Web App                              razor           [C#]          Web/MVC/Razor Pages
ASP.NET Core with Angular                         angular         [C#]          Web/MVC/SPA
ASP.NET Core with React.js                        react           [C#]          Web/MVC/SPA
ASP.NET Core with React.js and Redux              reactredux      [C#]          Web/MVC/SPA
ASP.NET Core Web API                              webapi          [C#], F#      Web/WebAPI

I hope you find this post on how to list dotnet core project templates using dotnet-cli helpful. Thanks for visiting. Cheers!!!

[Further Readings: How to create a dotnet core console app using dotnet-cli |  Top 7 Web Frameworks to Learn and Focus on in 2021 |  Top 7 Programming Languages to Focus on in 2021 |  Creational Design Patterns |   Abstract Factory Design Pattern in C#  |  Factory Method Pattern in C#  |  Singleton Design Pattern in C#  |  Introduction to Design Patterns  |  How to add Git Bash to Windows Terminal Application  |  How to customize Windows Terminal Application  |  How to customize Windows Terminal Key Bindings  |  How to use Blazor EditForm for Model Validation using C#  |  How to publish a Blazor Server Application to IIS  ]

2 3 votes
Article Rating
Subscribe
Notify of
guest
1 Comment
oldest
newest most voted
Inline Feedbacks
View all comments
1
0
Would love your thoughts, please comment.x
()
x