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

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 server appblazorserver[C#]Web/Blazor3.0
Blazor WebAssembly appblazorwasm[C#]Web/Blazor/WebAssembly3.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
ASP.NET Core with Angularangular[C#]Web/MVC/SPA2.0
ASP.NET Core with React.jsreact[C#]Web/MVC/SPA2.0
ASP.NET Core with React.js and Reduxreactredux[C#]Web/MVC/SPA2.0
Razor class libraryrazorclasslib[C#]Web/Razor/Library/Razor Class Library2.1
ASP.NET Core web APIwebapi[C#], F#Web/WebAPI1.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

Options

Template options

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

Examples

See Also

Info

2023-10-25 .NET Documentation