1dotnet new command - .NET Core CLI(1.)NET Codroetnet new command - .NET Core CLI(1)
2
3
4
7 dotnet new - Creates a new project, configuration file, or solution
8 based on the specified template.
9
11 .NET Core 2.1
12 dotnet new <TEMPLATE> [--force] [-i|--install] [-lang|--language] [-n|--name] [--nuget-source] [-o|--output]
13 [-u|--uninstall] [Template options]
14 dotnet new <TEMPLATE> [-l|--list] [--type]
15 dotnet new [-h|--help]
16
17 .NET Core 2.0
18 dotnet new <TEMPLATE> [--force] [-i|--install] [-lang|--language] [-n|--name] [-o|--output] [-u|--uninstall] [Template options]
19 dotnet new <TEMPLATE> [-l|--list] [--type]
20 dotnet new [-h|--help]
21
22 .NET Core 1.x
23 dotnet new <TEMPLATE> [-lang|--language] [-n|--name] [-o|--output] [-all|--show-all] [-h|--help] [Template options]
24 dotnet new <TEMPLATE> [-l|--list]
25 dotnet new [-all|--show-all]
26 dotnet new [-h|--help]
27
28 * * * * *
29
31 The dotnet new command provides a convenient way to initialize a valid
32 .NET Core project.
33
34 The command calls the template engine to create the artifacts on disk
35 based on the specified template and options.
36
37 Arguments
38 TEMPLATE
39
40 The template to instantiate when the command is invoked. Each template
41 might have specific options you can pass. For more information, see
42 Template options.
43
44 .NET Core 2.1
45 The command contains a default list of templates. Use dotnet new -l to
46 obtain a list of the available templates. The following table shows
47 the templates that come pre-installed with the .NET Core SDK 2.1.300.
48 The default language for the template is shown inside the brackets.
49
50 Template descrip‐ Template name Languages
51 tion
52 ───────────────────────────────────────────────────
53 Console application console [C#], F#, VB
54 Class library classlib [C#], F#, VB
55 Unit test project mstest [C#], F#, VB
56 xUnit test project xunit [C#], F#, VB
57 Razor page page [C#]
58 MVC ViewImports viewimports [C#]
59 MVC ViewStart viewstart [C#]
60 ASP.NET Core empty web [C#], F#
61 ASP.NET Core Web mvc [C#], F#
62 App (Mod‐
63 el-View-Controller)
64 ASP.NET Core Web razor [C#]
65 App
66
67 ASP.NET Core with angular [C#]
68 Angular
69 ASP.NET Core with react [C#]
70 React.js
71 ASP.NET Core with reactredux [C#]
72 React.js and Redux
73 ASP.NET Core Web webapi [C#], F#
74 API
75 Razor class library razorclasslib [C#]
76 global.json file globaljson
77 NuGet config nugetconfig
78 Web config webconfig
79 Solution file sln
80
81 .NET Core 2.0
82 The command contains a default list of templates. Use dotnet new -l to
83 obtain a list of the available templates. The following table shows
84 the templates that come pre-installed with the .NET Core SDK 2.0. The
85 default language for the template is shown inside the brackets.
86
87 Template descrip‐ Template name Languages
88 tion
89 ───────────────────────────────────────────────────
90 Console application console [C#], F#, VB
91 Class library classlib [C#], F#, VB
92 Unit test project mstest [C#], F#, VB
93 xUnit test project xunit [C#], F#, VB
94 ASP.NET Core empty web [C#], F#
95 ASP.NET Core Web mvc [C#], F#
96 App (Mod‐
97 el-View-Controller)
98 ASP.NET Core Web razor [C#]
99 App
100 ASP.NET Core with angular [C#]
101 Angular
102 ASP.NET Core with react [C#]
103 React.js
104 ASP.NET Core with reactredux [C#]
105 React.js and Redux
106 ASP.NET Core Web webapi [C#], F#
107 API
108 global.json file globaljson
109 NuGet config nugetconfig
110 Web config webconfig
111 Solution file sln
112 Razor page page
113 MVC ViewImports viewimports
114 MVC ViewStart viewstart
115
116 .NET Core 1.x
117 The command contains a default list of templates. Use dotnet new -all
118 to obtain a list of the available templates. The following table shows
119 the templates that come pre-installed with the .NET Core SDK 1.x. The
120 default language for the template is shown inside the brackets.
121
122 Template descrip‐ Template name Languages
123 tion
124 ────────────────────────────────────────────────
125 Console application console [C#], F#
126 Class library classlib [C#], F#
127 Unit test project mstest [C#], F#
128 xUnit test project xunit [C#], F#
129 ASP.NET Core empty web [C#]
130 ASP.NET Core Web mvc [C#], F#
131 App
132
133 ASP.NET Core Web webapi [C#]
134 API
135 NuGet config nugetconfig
136 Web config webconfig
137 Solution file sln
138
139 * * * * *
140
142 .NET Core 2.1
143 --force
144
145 Forces content to be generated even if it would change existing files.
146 This is required when the output directory already contains a project.
147
148 -h|--help
149
150 Prints out help for the command. It can be invoked for the dotnet new
151 command itself or for any template, such as dotnet new mvc --help.
152
153 -i|--install <PATH|NUGET_ID>
154
155 Installs a source or template pack from the PATH or NUGET_ID provided.
156 If you want to install a prerelease version of a template package, you
157 need to specify the version in the format of <package-name>::<pack‐
158 age-version>. By default, dotnet new passes * for the version, which
159 represents the last stable package version. See an example at the Ex‐
160 amples section.
161
162 For information on creating custom templates, see Custom templates for
163 dotnet new.
164
165 -l|--list
166
167 Lists templates containing the specified name. If invoked for the dot‐
168 net new command, it lists the possible templates available for the giv‐
169 en directory. For example if the directory already contains a project,
170 it doesn't list all project templates.
171
172 -lang|--language {C#|F#|VB}
173
174 The language of the template to create. The language accepted varies
175 by the template (see defaults in the arguments section). Not valid for
176 some templates.
177
178 > [!NOTE]
179 > Some shells interpret `#` as a special character. In those cases, you need to enclose the language parameter value, such as `dotnet new console -lang "F#"`.
180
181 -n|--name <OUTPUT_NAME>
182
183 The name for the created output. If no name is specified, the name of
184 the current directory is used.
185
186 --nuget-source
187
188 Specifies a NuGet source to use during install.
189
190 -o|--output <OUTPUT_DIRECTORY>
191
192 Location to place the generated output. The default is the current di‐
193 rectory.
194
195 --type
196
197 Filters templates based on available types. Predefined values are
198 “project”, “item” or “other”.
199
200 -u|--uninstall <PATH|NUGET_ID>
201
202 Uninstalls a source or template pack at the PATH or NUGET_ID provided.
203
204 [!NOTE] To uninstall a template using a PATH, you need to fully
205 qualify the path. For example, C:/Users/<USER>/Documents/Tem‐
206 plates/GarciaSoftware.ConsoleTemplate.CSharp will work, but
207 ./GarciaSoftware.ConsoleTemplate.CSharp from the containing
208 folder will not. Additionally, do not include a final terminat‐
209 ing directory slash on your template path.
210
211 .NET Core 2.0
212 --force
213
214 Forces content to be generated even if it would change existing files.
215 This is required when the output directory already contains a project.
216
217 -h|--help
218
219 Prints out help for the command. It can be invoked for the dotnet new
220 command itself or for any template, such as dotnet new mvc --help.
221
222 -i|--install <PATH|NUGET_ID>
223
224 Installs a source or template pack from the PATH or NUGET_ID provided.
225 If you want to install a prerelease version of a template package, you
226 need to specify the version in the format of <package-name>::<pack‐
227 age-version>. By default, dotnet new passes * for the version, which
228 represents the last stable package version. See an example at the Ex‐
229 amples section.
230
231 For information on creating custom templates, see Custom templates for
232 dotnet new.
233
234 -l|--list
235
236 Lists templates containing the specified name. If invoked for the dot‐
237 net new command, it lists the possible templates available for the giv‐
238 en directory. For example if the directory already contains a project,
239 it doesn't list all project templates.
240
241 -lang|--language {C#|F#|VB}
242
243 The language of the template to create. The language accepted varies
244 by the template (see defaults in the arguments section). Not valid for
245 some templates.
246
247 > [!NOTE]
248 > Some shells interpret `#` as a special character. In those cases, you need to enclose the language parameter value, such as `dotnet new console -lang "F#"`.
249
250 -n|--name <OUTPUT_NAME>
251
252 The name for the created output. If no name is specified, the name of
253 the current directory is used.
254
255 -o|--output <OUTPUT_DIRECTORY>
256
257 Location to place the generated output. The default is the current di‐
258 rectory.
259
260 --type
261
262 Filters templates based on available types. Predefined values are
263 “project”, “item” or “other”.
264
265 -u|--uninstall <PATH|NUGET_ID>
266
267 Uninstalls a source or template pack at the PATH or NUGET_ID provided.
268
269 [!NOTE] To uninstall a template using a PATH, you need to fully
270 qualify the path. For example, C:/Users/<USER>/Documents/Tem‐
271 plates/GarciaSoftware.ConsoleTemplate.CSharp will work, but
272 ./GarciaSoftware.ConsoleTemplate.CSharp from the containing
273 folder will not. Additionally, do not include a final terminat‐
274 ing directory slash on your template path.
275
276 .NET Core 1.x
277 -all|--show-all
278
279 Shows all templates for a specific type of project when running in the
280 context of the dotnet new command alone. When running in the context
281 of a specific template, such as dotnet new web -all, -all is interpret‐
282 ed as a force creation flag. This is required when the output directo‐
283 ry already contains a project.
284
285 -h|--help
286
287 Prints out help for the command. It can be invoked for the dotnet new
288 command itself or for any template, such as dotnet new mvc --help.
289
290 -l|--list
291
292 Lists templates containing the specified name. If invoked for the dot‐
293 net new command, it lists the possible templates available for the giv‐
294 en directory. For example if the directory already contains a project,
295 it doesn't list all project templates.
296
297 -lang|--language {C#|F#}
298
299 The language of the template to create. The language accepted varies
300 by the template (see defaults in the arguments section). Not valid for
301 some templates.
302
303 > [!NOTE]
304 > Some shells interpret `#` as a special character. In those cases, you need to enclose the language parameter value, such as `dotnet new console -lang "F#"`.
305
306 -n|--name <OUTPUT_NAME>
307
308 The name for the created output. If no name is specified, the name of
309 the current directory is used.
310
311 -o|--output <OUTPUT_DIRECTORY>
312
313 Location to place the generated output. The default is the current di‐
314 rectory.
315
316 * * * * *
317
318 Template options
319 Each project template may have additional options available. The core
320 templates have the following additional options:
321
322 .NET Core 2.1
323 console, angular, react, reactredux, razorclasslib
324
325 --no-restore - Doesn't execute an implicit restore during project cre‐
326 ation.
327
328 classlib
329
330 -f|--framework <FRAMEWORK> - Specifies the framework to target. Val‐
331 ues: netcoreapp2.0 to create a .NET Core Class Library or netstan‐
332 dard2.0 to create a .NET Standard Class Library. The default value is
333 netstandard2.0.
334
335 --no-restore - Doesn't execute an implicit restore during project cre‐
336 ation.
337
338 mstest, xunit
339
340 -p|--enable-pack - Enables packaging for the project using dotnet pack.
341
342 --no-restore - Doesn't execute an implicit restore during project cre‐
343 ation.
344
345 globaljson
346
347 --sdk-version <VERSION_NUMBER> - Specifies the version of the .NET Core
348 SDK to use in the global.json file.
349
350 web
351
352 --use-launch-settings - Includes launchSettings.json in the generated
353 template output.
354
355 --no-restore - Doesn't execute an implicit restore during project cre‐
356 ation.
357
358 webapi
359
360 -au|--auth <AUTHENTICATION_TYPE> - The type of authentication to use.
361 The possible values are:
362
363 · None - No authentication (Default).
364
365 · IndividualB2C - Individual authentication with Azure AD B2C.
366
367 · SingleOrg - Organizational authentication for a single tenant.
368
369 · Windows - Windows authentication.
370
371 --aad-b2c-instance <INSTANCE> - The Azure Active Directory B2C instance
372 to connect to. Use with IndividualB2C authentication. The default
373 value is https://login.microsoftonline.com/tfp/.
374
375 -ssp|--susi-policy-id <ID> - The sign-in and sign-up policy ID for this
376 project. Use with IndividualB2C authentication.
377
378 --aad-instance <INSTANCE> - The Azure Active Directory instance to con‐
379 nect to. Use with SingleOrg authentication. The default value is
380 https://login.microsoftonline.com/.
381
382 --client-id <ID> - The Client ID for this project. Use with Individu‐
383 alB2C or SingleOrg authentication. The default value is
384 11111111-1111-1111-11111111111111111.
385
386 --domain <DOMAIN> - The domain for the directory tenant. Use with Sin‐
387 gleOrg or IndividualB2C authentication. The default value is quali‐
388 fied.domain.name.
389
390 --tenant-id <ID> - The TenantId ID of the directory to connect to. Use
391 with SingleOrg authentication. The default value is
392 22222222-2222-2222-2222-222222222222.
393
394 -r|--org-read-access - Allows this application read-access to the di‐
395 rectory. Only applies to SingleOrg or MultiOrg authentication.
396
397 --use-launch-settings - Includes launchSettings.json in the generated
398 template output.
399
400 -uld|--use-local-db - Specifies LocalDB should be used instead of
401 SQLite. Only applies to Individual or IndividualB2C authentication.
402
403 --no-restore - Doesn't execute an implicit restore during project cre‐
404 ation.
405
406 mvc, razor
407
408 -au|--auth <AUTHENTICATION_TYPE> - The type of authentication to use.
409 The possible values are:
410
411 · None - No authentication (Default).
412
413 · Individual - Individual authentication.
414
415 · IndividualB2C - Individual authentication with Azure AD B2C.
416
417 · SingleOrg - Organizational authentication for a single tenant.
418
419 · MultiOrg - Organizational authentication for multiple tenants.
420
421 · Windows - Windows authentication.
422
423 --aad-b2c-instance <INSTANCE> - The Azure Active Directory B2C instance
424 to connect to. Use with IndividualB2C authentication. The default
425 value is https://login.microsoftonline.com/tfp/.
426
427 -ssp|--susi-policy-id <ID> - The sign-in and sign-up policy ID for this
428 project. Use with IndividualB2C authentication.
429
430 -rp|--reset-password-policy-id <ID> - The reset password policy ID for
431 this project. Use with IndividualB2C authentication.
432
433 -ep|--edit-profile-policy-id <ID> - The edit profile policy ID for this
434 project. Use with IndividualB2C authentication.
435
436 --aad-instance <INSTANCE> - The Azure Active Directory instance to con‐
437 nect to. Use with SingleOrg or MultiOrg authentication. The default
438 value is https://login.microsoftonline.com/.
439
440 --client-id <ID> - The Client ID for this project. Use with Individu‐
441 alB2C, SingleOrg, or MultiOrg authentication. The default value is
442 11111111-1111-1111-11111111111111111.
443
444 --domain <DOMAIN> - The domain for the directory tenant. Use with Sin‐
445 gleOrg or IndividualB2C authentication. The default value is quali‐
446 fied.domain.name.
447
448 --tenant-id <ID> - The TenantId ID of the directory to connect to. Use
449 with SingleOrg authentication. The default value is
450 22222222-2222-2222-2222-222222222222.
451
452 --callback-path <PATH> - The request path within the application's base
453 path of the redirect URI. Use with SingleOrg or IndividualB2C authen‐
454 tication. The default value is /signin-oidc.
455
456 -r|--org-read-access - Allows this application read-access to the di‐
457 rectory. Only applies to SingleOrg or MultiOrg authentication.
458
459 --use-launch-settings - Includes launchSettings.json in the generated
460 template output.
461
462 --use-browserlink - Includes BrowserLink in the project.
463
464 -uld|--use-local-db - Specifies LocalDB should be used instead of
465 SQLite. Only applies to Individual or IndividualB2C authentication.
466
467 --no-restore - Doesn't execute an implicit restore during project cre‐
468 ation.
469
470 page
471
472 -na|--namespace <NAMESPACE_NAME>- Namespace for the generated code.
473 The default value is MyApp.Namespace.
474
475 -np|--no-pagemodel - Creates the page without a PageModel.
476
477 viewimports
478
479 -na|--namespace <NAMESPACE_NAME>- Namespace for the generated code.
480 The default value is MyApp.Namespace.
481
482 .NET Core 2.0
483 console, angular, react, reactredux
484
485 --no-restore - Doesn't execute an implicit restore during project cre‐
486 ation.
487
488 classlib
489
490 -f|--framework <FRAMEWORK> - Specifies the framework to target. Val‐
491 ues: netcoreapp2.0 to create a .NET Core Class Library or netstan‐
492 dard2.0 to create a .NET Standard Class Library. The default value is
493 netstandard2.0.
494
495 --no-restore - Doesn't execute an implicit restore during project cre‐
496 ation.
497
498 mstest, xunit
499
500 -p|--enable-pack - Enables packaging for the project using dotnet pack.
501
502 --no-restore - Doesn't execute an implicit restore during project cre‐
503 ation.
504
505 globaljson
506
507 --sdk-version <VERSION_NUMBER> - Specifies the version of the .NET Core
508 SDK to use in the global.json file.
509
510 web
511
512 --use-launch-settings - Includes launchSettings.json in the generated
513 template output.
514
515 --no-restore - Doesn't execute an implicit restore during project cre‐
516 ation.
517
518 webapi
519
520 -au|--auth <AUTHENTICATION_TYPE> - The type of authentication to use.
521 The possible values are:
522
523 · None - No authentication (Default).
524
525 · IndividualB2C - Individual authentication with Azure AD B2C.
526
527 · SingleOrg - Organizational authentication for a single tenant.
528
529 · Windows - Windows authentication.
530
531 --aad-b2c-instance <INSTANCE> - The Azure Active Directory B2C instance
532 to connect to. Use with IndividualB2C authentication. The default
533 value is https://login.microsoftonline.com/tfp/.
534
535 -ssp|--susi-policy-id <ID> - The sign-in and sign-up policy ID for this
536 project. Use with IndividualB2C authentication.
537
538 --aad-instance <INSTANCE> - The Azure Active Directory instance to con‐
539 nect to. Use with SingleOrg authentication. The default value is
540 https://login.microsoftonline.com/.
541
542 --client-id <ID> - The Client ID for this project. Use with Individu‐
543 alB2C or SingleOrg authentication. The default value is
544 11111111-1111-1111-11111111111111111.
545
546 --domain <DOMAIN> - The domain for the directory tenant. Use with Sin‐
547 gleOrg or IndividualB2C authentication. The default value is quali‐
548 fied.domain.name.
549
550 --tenant-id <ID> - The TenantId ID of the directory to connect to. Use
551 with SingleOrg authentication. The default value is
552 22222222-2222-2222-2222-222222222222.
553
554 -r|--org-read-access - Allows this application read-access to the di‐
555 rectory. Only applies to SingleOrg or MultiOrg authentication.
556
557 --use-launch-settings - Includes launchSettings.json in the generated
558 template output.
559
560 -uld|--use-local-db - Specifies LocalDB should be used instead of
561 SQLite. Only applies to Individual or IndividualB2C authentication.
562
563 --no-restore - Doesn't execute an implicit restore during project cre‐
564 ation.
565
566 mvc, razor
567
568 -au|--auth <AUTHENTICATION_TYPE> - The type of authentication to use.
569 The possible values are:
570
571 · None - No authentication (Default).
572
573 · Individual - Individual authentication.
574
575 · IndividualB2C - Individual authentication with Azure AD B2C.
576
577 · SingleOrg - Organizational authentication for a single tenant.
578
579 · MultiOrg - Organizational authentication for multiple tenants.
580
581 · Windows - Windows authentication.
582
583 --aad-b2c-instance <INSTANCE> - The Azure Active Directory B2C instance
584 to connect to. Use with IndividualB2C authentication. The default
585 value is https://login.microsoftonline.com/tfp/.
586
587 -ssp|--susi-policy-id <ID> - The sign-in and sign-up policy ID for this
588 project. Use with IndividualB2C authentication.
589
590 -rp|--reset-password-policy-id <ID> - The reset password policy ID for
591 this project. Use with IndividualB2C authentication.
592
593 -ep|--edit-profile-policy-id <ID> - The edit profile policy ID for this
594 project. Use with IndividualB2C authentication.
595
596 --aad-instance <INSTANCE> - The Azure Active Directory instance to con‐
597 nect to. Use with SingleOrg or MultiOrg authentication. The default
598 value is https://login.microsoftonline.com/.
599
600 --client-id <ID> - The Client ID for this project. Use with Individu‐
601 alB2C, SingleOrg, or MultiOrg authentication. The default value is
602 11111111-1111-1111-11111111111111111.
603
604 --domain <DOMAIN> - The domain for the directory tenant. Use with Sin‐
605 gleOrg or IndividualB2C authentication. The default value is quali‐
606 fied.domain.name.
607
608 --tenant-id <ID> - The TenantId ID of the directory to connect to. Use
609 with SingleOrg authentication. The default value is
610 22222222-2222-2222-2222-222222222222.
611
612 --callback-path <PATH> - The request path within the application's base
613 path of the redirect URI. Use with SingleOrg or IndividualB2C authen‐
614 tication. The default value is /signin-oidc.
615
616 -r|--org-read-access - Allows this application read-access to the di‐
617 rectory. Only applies to SingleOrg or MultiOrg authentication.
618
619 --use-launch-settings - Includes launchSettings.json in the generated
620 template output.
621
622 --use-browserlink - Includes BrowserLink in the project.
623
624 -uld|--use-local-db - Specifies LocalDB should be used instead of
625 SQLite. Only applies to Individual or IndividualB2C authentication.
626
627 --no-restore - Doesn't execute an implicit restore during project cre‐
628 ation.
629
630 page
631
632 -na|--namespace <NAMESPACE_NAME>- Namespace for the generated code.
633 The default value is MyApp.Namespace.
634
635 -np|--no-pagemodel - Creates the page without a PageModel.
636
637 viewimports
638
639 -na|--namespace <NAMESPACE_NAME>- Namespace for the generated code.
640 The default value is MyApp.Namespace.
641
642 .NET Core 1.x
643 console, xunit, mstest, web, webapi
644
645 -f|--framework - Specifies the framework to target. Values: netcore‐
646 app1.0 or netcoreapp1.1. The default value is netcoreapp1.0.
647
648 classlib
649
650 -f|--framework - Specifies the framework to target. Values: netcore‐
651 app1.0, netcoreapp1.1, or netstandard1.0 to netstandard1.6. The de‐
652 fault value is netstandard1.4.
653
654 mvc
655
656 -f|--framework - Specifies the framework to target. Values: netcore‐
657 app1.0 or netcoreapp1.1. The default value is netcoreapp1.0.
658
659 -au|--auth - The type of authentication to use. Values: None or Indi‐
660 vidual. The default value is None.
661
662 -uld|--use-local-db - Specifies whether or not to use LocalDB instead
663 of SQLite. Values: true or false. The default value is false.
664
665 * * * * *
666
668 Create an F# console application project in the current directory:
669
670 dotnet new console -lang F#
671
672 Create a .NET Standard class library project in the specified directory
673 (available only with .NET Core SDK 2.0 or later versions):
674
675 dotnet new classlib -lang VB -o MyLibrary
676
677 Create a new ASP.NET Core C# MVC application project in the current di‐
678 rectory with no authentication targeting .NET Core 2.0:
679
680 dotnet new mvc -au None -f netcoreapp2.0
681
682 Create a new xUnit application targeting .NET Core 2.0:
683
684 dotnet new xunit --framework netcoreapp2.0
685
686 List all templates available for MVC:
687
688 dotnet new mvc -l
689
690 Install version 2.0 of the Single Page Application templates for
691 ASP.NET Core (command option available for .NET Core SDK 1.1 and later
692 versions only):
693
694 dotnet new -i Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0
695
696 Create a global.json in the current directory setting the SDK version
697 to 2.0.0 (available only with .NET Core SDK 2.0 or later versions):
698
699 dotnet new globaljson --sdk-version 2.0.0
700
701 See also
702 Custom templates for dotnet new
703 Create a custom template for dotnet new
704 dotnet/dotnet-template-samples GitHub repo
705 Available templates for dotnet new
706
708 mairaw.
709
710
711
712 dotnet new command - .NET Core CLI(1)