1dotnet-new(1)                 .NET Documentation                 dotnet-new(1)
2
3
4

dotnet new <TEMPLATE>

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

NAME

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

SYNOPSIS

13              dotnet new <TEMPLATE> [--dry-run] [--force] [-lang|--language {"C#"|"F#"|VB}]
14                  [-n|--name <OUTPUT_NAME>] [--no-update-check]
15                  [-o|--output <OUTPUT_DIRECTORY>] [--project <PROJECT_PATH>]
16                  [-d|--diagnostics] [--verbosity <LEVEL>] [Template options]
17
18              dotnet new -h|--help
19

DESCRIPTION

21       The dotnet new command creates a .NET project or other artifacts  based
22       on a template.
23
24       The  command  calls the template engine (https://github.com/dotnet/tem
25       plating) to create the artifacts on disk based on  the  specified  tem‐
26       plate and options.
27
28       Starting with the .NET 7 SDK, the dotnet new syntax has changed:
29
30       • The --list, --search, --install, and --uninstall options became list,
31         search, install and uninstall subcommands.
32
33       • The --update-apply option became the update subcommand.
34
35       • To use --update-check, use the update subcommand with the --check-on‐
36         ly option.
37
38       Other  options  that  were  available before are still available to use
39       with their respective subcommands.  Separate help for  each  subcommand
40       is  available  via  the  -h  or  --help option: dotnet new <subcommand>
41       --help lists all supported options for the subcommand.
42
43       Additionally, tab completion is now available for dotnet new.  It  sup‐
44       ports completion for installed template names and for the options a se‐
45       lected template provides.  To activate tab completion for the .NET SDK,
46       see Enable tab completion.
47
48   Tab completion
49       Starting  with .NET SDK 7.0.100, tab completion is available for dotnet
50       new.  It supports completion for installed template names, as  well  as
51       completion  for  the options a selected template provides.  To activate
52       tab completion for the .NET SDK, see Enable tab completion.
53
54   Implicit restore
55       You don’t have to run dotnet restore because it’s run implicitly by all
56       commands  that  require  a restore to occur, such as dotnet new, dotnet
57       build, dotnet run, dotnet test, dotnet publish, and  dotnet  pack.   To
58       disable implicit restore, use the --no-restore option.
59
60       The  dotnet  restore command is still useful in certain scenarios where
61       explicitly restoring makes sense, such as continuous integration builds
62       in  Azure  DevOps  Services or in build systems that need to explicitly
63       control when the restore occurs.
64
65       For information about how to manage NuGet feeds, see the dotnet restore
66       documentation.
67

ARGUMENTS

69TEMPLATE
70
71         The  template  to instantiate when the command is invoked.  Each tem‐
72         plate might have specific options you can pass.   For  more  informa‐
73         tion, see Template options.
74
75         You can run dotnet new list to see a list of all installed templates.
76
77         Starting with .NET Core 3.0 SDK and ending with .NET SDK 5.0.300, the
78         CLI searches for templates in NuGet.org when you  invoke  the  dotnet
79         new command in the following conditions:
80
81         • If  the  CLI  can’t find a template match when invoking dotnet new,
82           not even partial.
83
84         • If there’s a newer version of  the  template  available.   In  this
85           case,  the  project  or  artifact  is created but the CLI warns you
86           about an updated version of the template.
87
88         Starting with .NET SDK 5.0.300, the search command should be used  to
89         search for templates in NuGet.org.
90
91         The  following table shows the templates that come pre-installed with
92         the .NET SDK.  The default language for the template is shown  inside
93         the  brackets.  Click on the short name link to see the specific tem‐
94         plate options.
95
96       Templates       Short name      Language       Tags            Introduced
97       ─────────────────────────────────────────────────────────────────────────────
98       Console   Ap‐   console         [C#], F#, VB   Common/Con‐     1.0
99       plication                                      sole
100       Class library   classlib        [C#], F#, VB   Common/Li‐      1.0
101                                                      brary
102       WPF  Applica‐   wpf             [C#], VB       Common/WPF      3.0 (5.0  for
103       tion                                                           VB)
104       WPF Class li‐   wpflib          [C#], VB       Common/WPF      3.0 (5.0  for
105       brary                                                          VB)
106       WPF    Custom   wpfcustomcon‐   [C#], VB       Common/WPF      3.0 (5.0  for
107       Control   Li‐   trollib                                        VB)
108       brary
109       WPF User Con‐   wpfusercon‐     [C#], VB       Common/WPF      3.0  (5.0 for
110       trol Library    trollib                                        VB)
111       Windows Forms   winforms        [C#], VB       Common/Win‐     3.0  (5.0 for
112       (WinForms)                                     Forms           VB)
113       Application
114       Windows Forms   winformslib     [C#], VB       Common/Win‐     3.0  (5.0 for
115       (WinForms)                                     Forms           VB)
116       Class library
117       Worker   Ser‐   worker          [C#]           Common/Work‐    3.0
118       vice                                           er/Web
119       Unit     Test   mstest          [C#], F#, VB   Test/MSTest     1.0
120       Project
121       NUnit  3 Test   nunit           [C#], F#, VB   Test/NUnit      2.1.400
122       Project
123       NUnit 3  Test   nunit-test      [C#], F#, VB   Test/NUnit      2.2
124       Item
125       xUnit    Test   xunit           [C#], F#, VB   Test/xUnit      1.0
126       Project
127       Razor  Compo‐   razorcompo‐     [C#]           Web/ASP.NET     3.0
128       nent            nent
129       Razor Page      page            [C#]           Web/ASP.NET     2.0
130       MVC   ViewIm‐   viewimports     [C#]           Web/ASP.NET     2.0
131       ports
132
133       MVC ViewStart   viewstart       [C#]           Web/ASP.NET     2.0
134       Blazor Server   blazorserver    [C#]           Web/Blazor      3.0
135       App
136       Blazor    We‐   blazorwasm      [C#]           Web/Bla‐        3.1.300
137       bAssembly App                                  zor/WebAssem‐
138                                                      bly
139       ASP.NET  Core   web             [C#], F#       Web/Empty       1.0
140       Empty
141       ASP.NET  Core   mvc             [C#], F#       Web/MVC         1.0
142       Web App (Mod‐
143       el-View-Con‐
144       troller)
145       ASP.NET  Core   webapp, razor   [C#]           Web/MVC/Razor   2.2, 2.0
146       Web App                                        Pages
147       ASP.NET  Core   angular         [C#]           Web/MVC/SPA     2.0
148       with Angular
149       ASP.NET  Core   react           [C#]           Web/MVC/SPA     2.0
150       with React.js
151       ASP.NET  Core   reactredux      [C#]           Web/MVC/SPA     2.0
152       with React.js
153       and Redux
154       Razor   Class   razorclasslib   [C#]           Web/Razor/Li‐   2.1
155       Library                                        brary/Razor
156                                                      Class Library
157       ASP.NET  Core   webapi          [C#], F#       Web/WebAPI      1.0
158       Web API
159       ASP.NET  Core   grpc            [C#]           Web/gRPC        3.0
160       gRPC Service
161       dotnet gitig‐   gitignore                      Config          3.0
162       nore file
163       global.json     globaljson                     Config          2.0
164       file
165       NuGet Config    nugetconfig                    Config          1.0
166       Dotnet  local   tool-manifest                  Config          3.0
167       tool manifest
168       file
169       Web Config      webconfig                      Config          1.0
170       Solution File   sln                            Solution        1.0
171       Protocol Buf‐   proto                          Web/gRPC        3.0
172       fer File
173       EditorConfig    editorconfig                   Config          6.0
174       file
175

OPTIONS

177--dry-run
178
179         Displays a summary of what would happen if the given command were run
180         if it would result in a template creation.  Available since .NET Core
181         2.2 SDK.
182
183--force
184
185         Forces content to be generated  even  if  it  would  change  existing
186         files.   This is required when the template chosen would override ex‐
187         isting files in the output directory.
188
189-?|-h|--help
190
191         Prints out help for the command.  It can be invoked  for  the  dotnet
192         new  command itself or for any template.  For example, dotnet new mvc
193         --help.
194
195-lang|--language {C#|F#|VB}
196
197         The language of the template to create.  The language accepted varies
198         by  the  template (see defaults in the arguments section).  Not valid
199         for some templates.
200
201                Some shells interpret # as a special character.  In those cas‐
202                es, enclose the language parameter value in quotes.  For exam‐
203                ple, dotnet new console -lang "F#".
204
205-n|--name <OUTPUT_NAME>
206
207         The name for the created output.  If no name is specified,  the  name
208         of the current directory is used.
209
210-no-update-check
211
212         Disables  checking  for template package updates when instantiating a
213         template.  Available since .NET SDK 6.0.100.  When instantiating  the
214         template  from  a template package that was installed by using dotnet
215         new --install, dotnet new checks if there is an update for  the  tem‐
216         plate.   Starting with .NET 6, no update checks are done for .NET de‐
217         fault templates.  To update .NET default templates, install the patch
218         version of the .NET SDK.
219
220-o|--output <OUTPUT_DIRECTORY>
221
222         Location  to  place the generated output.  The default is the current
223         directory.
224
225--project <PROJECT_PATH>
226
227         The project that the template is added to.  This project is used  for
228         context  evaluation.  If not specified, the project in the current or
229         parent directories will be used.  Available since .NET SDK 7.0.100.
230
231-d|--diagnostics
232
233         Enables diagnostic output.  Available since .NET SDK 7.0.100.
234
235-v|--verbosity <LEVEL>
236
237         Sets the verbosity level of the command.  Allowed values are q[uiet],
238         m[inimal],  n[ormal],  and  diag[nostic].   Available  since .NET SDK
239         7.0.100.
240
241   Template options
242       Each template may have additional options defined.  For  more  informa‐
243       tion, see .NET default templates for dotnet new.
244

EXAMPLES

246       • Create a C# console application project:
247
248                dotnet new console
249
250       • Create an F# console application project in the current directory:
251
252                dotnet new console --language "F#"
253
254       • Create a .NET Standard 2.0 class library project in the specified di‐
255         rectory:
256
257                dotnet new classlib --framework "netstandard2.0" -o MyLibrary
258
259       • Create a new ASP.NET Core C# MVC project  in  the  current  directory
260         with no authentication:
261
262                dotnet new mvc -au None
263
264       • Create a new xUnit project:
265
266                dotnet new xunit
267
268       • Create a global.json in the current directory setting the SDK version
269         to 3.1.101:
270
271                dotnet new globaljson --sdk-version 3.1.101
272
273       • Show help for the C# console application template:
274
275                dotnet new console -h
276
277       • Show help for the F# console application template:
278
279                dotnet new console --language "F#" -h
280

SEE ALSO

282       • dotnet new list command
283
284       • dotnet new search command
285
286       • dotnet new install command
287
288       • .NET default templates for dotnet new
289
290       • Custom templates for dotnet new
291
292       • Create a custom template for dotnet new
293
294
295
296                                  2022-11-08                     dotnet-new(1)