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 this 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 need to have .NET Core 1.x or above installed on his machine.

Command Options:

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

  • 1. Long format: –list
  • 2. Short format: -l
dotnet core, NET Core, dotnet-cli, dotnet core project template
Display Pre-installed NET Core project templates

Command Usage Example:

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.

Further Usage:

The user can use the “dotnet new –list” command to filter the template of 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

Read about: How to create dotnet core console app and dotnet core class library

Download latest version of NET Core or refer MSDN for further details

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments