dotnet-new - Man Page

Creates a new project, configuration file, or solution based on the specified template.

dotnet new <TEMPLATE>

This article applies to: ✔️ .NET Core 3.1 SDK and later versions

Synopsis

dotnet new <TEMPLATE> [--dry-run] [--force] [-lang|--language {"C#"|"F#"|VB}]
    [-n|--name <OUTPUT_NAME>] [-f|--framework <FRAMEWORK>] [--no-update-check]
    [-o|--output <OUTPUT_DIRECTORY>] [--project <PROJECT_PATH>]
    [-d|--diagnostics] [--verbosity <LEVEL>] [Template options]

dotnet new -h|--help

Description

The dotnet new command creates a .NET project or other artifacts based on a template.

The command calls the template engine (https://github.com/dotnet/templating) to create the artifacts on disk based on the specified template and options.

Starting with the .NET 7 SDK, the dotnet new syntax has changed:

Other options that were available before are still available to use with their respective subcommands. Separate help for each subcommand is available via the -h or --help option: dotnet new <subcommand> --help lists all supported options for the subcommand.

Additionally, tab completion is now available for dotnet new. It supports completion for installed template names and for the options a selected template provides. To activate tab completion for the .NET SDK, see Enable tab completion.

Tab completion

Starting with .NET SDK 7.0.100, tab completion is available for dotnet new. It supports completion for installed template names, as well as completion for the options a selected template provides. To activate tab completion for the .NET SDK, see Enable tab completion.

Implicit restore

You don’t have to run dotnet restore because it’s run implicitly by all commands that require a restore to occur, such as dotnet new, dotnet build, dotnet run, dotnet test, dotnet publish, and dotnet pack. To disable implicit restore, use the --no-restore option.

The dotnet restore command is still useful in certain scenarios where explicitly restoring makes sense, such as continuous integration builds in Azure DevOps Services or in build systems that need to explicitly control when the restore occurs.

For information about how to manage NuGet feeds, see the dotnet restore documentation.

Arguments

The following table shows the templates that come pre-installed with the .NET SDK. The default language for the template is shown inside the brackets. Click on the short name link to see the specific template options.

TemplatesShort nameLanguageTagsIntroduced
Console Applicationconsole[C#], F#, VBCommon/Console1.0
Class libraryclasslib[C#], F#, VBCommon/Library1.0
WPF Applicationwpf[C#], VBCommon/WPF3.0 (5.0 for VB)
WPF Class librarywpflib[C#], VBCommon/WPF3.0 (5.0 for VB)
WPF Custom Control Librarywpfcustomcontrollib[C#], VBCommon/WPF3.0 (5.0 for VB)
WPF User Control Librarywpfusercontrollib[C#], VBCommon/WPF3.0 (5.0 for VB)
Windows Forms (WinForms) Applicationwinforms[C#], VBCommon/WinForms3.0 (5.0 for VB)
Windows Forms (WinForms) Class librarywinformslib[C#], VBCommon/WinForms3.0 (5.0 for VB)
Worker Serviceworker[C#]Common/Worker/Web3.0
Unit Test Projectmstest[C#], F#, VBTest/MSTest1.0
NUnit 3 Test Projectnunit[C#], F#, VBTest/NUnit2.1.400
NUnit 3 Test Itemnunit-test[C#], F#, VBTest/NUnit2.2
xUnit Test Projectxunit[C#], F#, VBTest/xUnit1.0
Razor Componentrazorcomponent[C#]Web/ASP.NET3.0
Razor Pagepage[C#]Web/ASP.NET2.0
MVC ViewImportsviewimports[C#]Web/ASP.NET2.0
MVC ViewStartviewstart[C#]Web/ASP.NET2.0
Blazor Web Appblazor[C#]Web/Blazor8.0.100
Blazor WebAssembly Standalone Appblazorwasm[C#]Web/Blazor/WebAssembly/PWA3.1.300
ASP.NET Core Emptyweb[C#], F#Web/Empty1.0
ASP.NET Core Web App (Model-View-Controller)mvc[C#], F#Web/MVC1.0
ASP.NET Core Web Appwebapp, razor[C#]Web/MVC/Razor Pages2.2, 2.0
Razor Class Libraryrazorclasslib[C#]Web/Razor/Library/Razor Class Library2.1
ASP.NET Core Web APIwebapi[C#], F#Web/Web API/API/Service/WebAPI1.0
ASP.NET Core APIwebapiaot[C#]Web/Web API/API/Service8.0
ASP.NET Core API controllerapicontroller[C#]Web/ASP.NET8.0
ASP.NET Core gRPC Servicegrpc[C#]Web/gRPC3.0
dotnet gitignore filegitignoreConfig3.0
global.json fileglobaljsonConfig2.0
NuGet ConfignugetconfigConfig1.0
Dotnet local tool manifest filetool-manifestConfig3.0
Web ConfigwebconfigConfig1.0
Solution FileslnSolution1.0
Protocol Buffer FileprotoWeb/gRPC3.0
EditorConfig fileeditorconfigConfig6.0

The following table shows templates that have been discontinued and no longer come pre-installed with the .NET SDK. Click on the short name link to see the specific template options.

TemplatesShort nameLanguageTagsDiscontinued since
ASP.NET Core with Angularangular[C#]Web/MVC/SPA8.0
ASP.NET Core with React.jsreact[C#]Web/MVC/SPA8.0
Blazor Server Appblazorserver[C#]Web/Blazor8.0
Blazor Server App Emptyblazorserver-empty[C#]Web/Blazor8.0
Blazor WebAssembly App Emptyblazorwasm-empty[C#]Web/Blazor/WebAssembly8.0

Options

Template options

Each template may have additional options defined. For more information, see .NET default templates for dotnet new.

Examples

See Also

Info

2024-10-02 .NET Documentation