Provided by: dotnet-host_6.0.136-0ubuntu1~22.04.1_amd64 bug

dotnet new

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

NAME

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

SYNOPSIS

              dotnet new <TEMPLATE> [--dry-run] [--force] [-lang|--language {"C#"|"F#"|VB}]
                  [-n|--name <OUTPUT_NAME>] [-o|--output <OUTPUT_DIRECTORY>] [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.

   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 explicit‐
       ly control when the restore occurs.

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

   ArgumentsTEMPLATE

         The template to instantiate when the command is invoked.  Each template might have specific options you
         can pass.  For more information, see Template options.

         You can run dotnet new --list to see a list of all installed templates.

         Starting with .NET Core 3.0 SDK and ending with .NET Core 5.0.300 SDK, the CLI searches  for  templates
         in NuGet.org when you invoke the dotnet new command in the following conditions:

         • If the CLI can’t find a template match when invoking dotnet new, not even partial.

         • If  there’s a newer version of the template available.  In this case, the project or artifact is cre‐
           ated but the CLI warns you about an updated version of the template.

         Starting with .NET Core 5.0.300 SDK, the --search option should be used  to  search  for  templates  in
         NuGet.org..

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

       Templates             Short name            Language       Tags                  Introduced
       ──────────────────────────────────────────────────────────────────────────────────────────────────
       Console Application   console               [C#], F#, VB   Common/Console        1.0
       Class library         classlib              [C#], F#, VB   Common/Library        1.0
       WPF Application       wpf                   [C#], VB       Common/WPF            3.0 (5.0 for VB)
       WPF Class library     wpflib                [C#], VB       Common/WPF            3.0 (5.0 for VB)
       WPF  Custom Control   wpfcustomcontrollib   [C#], VB       Common/WPF            3.0 (5.0 for VB)
       Library
       WPF  User   Control   wpfusercontrollib     [C#], VB       Common/WPF            3.0 (5.0 for VB)
       Library
       Windows Forms (Win‐   winforms              [C#], VB       Common/WinForms       3.0 (5.0 for VB)
       Forms) Application
       Windows Forms (Win‐   winformslib           [C#], VB       Common/WinForms       3.0 (5.0 for VB)
       Forms)   Class  li‐
       brary
       Worker Service        worker                [C#]           Common/Worker/Web     3.0
       Unit Test Project     mstest                [C#], F#, VB   Test/MSTest           1.0
       NUnit    3     Test   nunit                 [C#], F#, VB   Test/NUnit            2.1.400
       Project
       NUnit 3 Test Item     nunit-test            [C#], F#, VB   Test/NUnit            2.2
       xUnit Test Project    xunit                 [C#], F#, VB   Test/xUnit            1.0
       Razor Component       razorcomponent        [C#]           Web/ASP.NET           3.0
       Razor Page            page                  [C#]           Web/ASP.NET           2.0
       MVC ViewImports       viewimports           [C#]           Web/ASP.NET           2.0
       MVC ViewStart         viewstart             [C#]           Web/ASP.NET           2.0
       Blazor Server App     blazorserver          [C#]           Web/Blazor            3.0
       Blazor  WebAssembly   blazorwasm            [C#]           Web/Blazor/We‐        3.1.300
       App                                                        bAssembly
       ASP.NET Core Empty    web                   [C#], F#       Web/Empty             1.0
       ASP.NET  Core   Web   mvc                   [C#], F#       Web/MVC               1.0
       App    (Model-View-
       Controller)
       ASP.NET  Core   Web   webapp, razor         [C#]           Web/MVC/Razor Pages   2.2, 2.0
       App
       ASP.NET  Core  with   angular               [C#]           Web/MVC/SPA           2.0
       Angular
       ASP.NET  Core  with   react                 [C#]           Web/MVC/SPA           2.0
       React.js
       ASP.NET  Core  with   reactredux            [C#]           Web/MVC/SPA           2.0
       React.js and Redux
       Razor Class Library   razorclasslib         [C#]           Web/Razor/Li‐         2.1
                                                                  brary/Razor   Class
                                                                  Library
       ASP.NET   Core  Web   webapi                [C#], F#       Web/WebAPI            1.0
       API
       ASP.NET  Core  gRPC   grpc                  [C#]           Web/gRPC              3.0
       Service
       dotnet    gitignore   gitignore                            Config                3.0
       file
       global.json file      globaljson                           Config                2.0
       NuGet Config          nugetconfig                          Config                1.0
       Dotnet  local  tool   tool-manifest                        Config                3.0
       manifest file
       Web Config            webconfig                            Config                1.0
       Solution File         sln                                  Solution              1.0
       Protocol     Buffer   proto                                Web/gRPC              3.0
       File

OPTIONS

--dry-run

         Displays a summary of what would happen if the given command were run if it would result in a  template
         creation.  Available since .NET Core 2.2 SDK.

       • --force

         Forces  content to be generated even if it would change existing files.  This is required when the tem‐
         plate chosen would override existing files in the output directory.

       • -?|-h|--help

         Prints out help for the command.  It can be invoked for the dotnet new command itself or for  any  tem‐
         plate.  For example, dotnet new mvc --help.

       • -lang|--language {C#|F#|VB}

         The  language of the template to create.  The language accepted varies by the template (see defaults in
         the arguments section).  Not valid for some templates.

                [!NOTE] Some shells interpret # as a special character.  In those cases,  enclose  the  language
                parameter value in quotes.  For example, dotnet new console -lang "F#".

       • -n|--name <OUTPUT_NAME>

         The name for the created output.  If no name is specified, the name of the current directory is used.

       • -o|--output <OUTPUT_DIRECTORY>

         Location to place the generated output.  The default is the current directory.

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

EXAMPLES

       • Create a C# console application project:

                dotnet new console

       • Create an F# console application project in the current directory:

                dotnet new console --language "F#"

       • Create a .NET Standard 2.0 class library project in the specified directory:

                dotnet new classlib --framework "netstandard2.0" -o MyLibrary

       • Create a new ASP.NET Core C# MVC project in the current directory with no authentication:

                dotnet new mvc -au None

       • Create a new xUnit project:

                dotnet new xunit

       • Create a global.json in the current directory setting the SDK version to 3.1.101:

                dotnet new globaljson --sdk-version 3.1.101

   See also
       • dotnet new –list option

       • dotnet new –search option

       • dotnet new –install option

       • .NET default templates for dotnet new

       • Custom templates for dotnet new

       • Create a custom template for dotnet new

       • dotnet/dotnet-template-samples GitHub repo (https://github.com/dotnet/dotnet-template-samples)

                                                                                                             (1)