1(1) .NET (1)
2
3
4
6 This article applies to: ✔️ .NET Core 2.0 SDK and later versions
7
9 dotnet new - Creates a new project, configuration file, or solution
10 based on the specified template.
11
13 dotnet new <TEMPLATE> [--dry-run] [--force] [-lang|--language {"C#"|"F#"|VB}]
14 [-n|--name <OUTPUT_NAME>] [-o|--output <OUTPUT_DIRECTORY>] [Template options]
15
16 dotnet new -h|--help
17
19 The dotnet new command creates a .NET project or other artifacts based
20 on a template.
21
22 The command calls the template engine (https://github.com/dotnet/tem‐
23 plating) to create the artifacts on disk based on the specified tem‐
24 plate and options.
25
26 Implicit restore
27 You don’t have to run dotnet restore because it’s run implicitly by all
28 commands that require a restore to occur, such as dotnet new, dotnet
29 build, dotnet run, dotnet test, dotnet publish, and dotnet pack. To
30 disable implicit restore, use the --no-restore option.
31
32 The dotnet restore command is still useful in certain scenarios where
33 explicitly restoring makes sense, such as continuous integration builds
34 in Azure DevOps Services or in build systems that need to explicitly
35 control when the restore occurs.
36
37 For information about how to manage NuGet feeds, see the dotnet restore
38 documentation.
39
40 Arguments
41 • TEMPLATE
42
43 The template to instantiate when the command is invoked. Each tem‐
44 plate might have specific options you can pass. For more informa‐
45 tion, see Template options.
46
47 You can run dotnet new --list to see a list of all installed tem‐
48 plates.
49
50 Starting with .NET Core 3.0 SDK and ending with .NET Core 5.0.300
51 SDK, the CLI searches for templates in NuGet.org when you invoke the
52 dotnet new command in the following conditions:
53
54 • If the CLI can’t find a template match when invoking dotnet new,
55 not even partial.
56
57 • If there’s a newer version of the template available. In this
58 case, the project or artifact is created but the CLI warns you
59 about an updated version of the template.
60
61 Starting with .NET Core 5.0.300 SDK, the --search option should be
62 used to search for templates in NuGet.org..
63
64 The following table shows the templates that come pre-installed with
65 the .NET SDK. The default language for the template is shown inside
66 the brackets. Click on the short name link to see the specific tem‐
67 plate options.
68
69 Templates Short name Language Tags Introduced
70 ─────────────────────────────────────────────────────────────────────────────
71 Console Ap‐ console [C#], F#, VB Common/Con‐ 1.0
72 plication sole
73 Class library classlib [C#], F#, VB Common/Li‐ 1.0
74 brary
75 WPF Applica‐ wpf [C#], VB Common/WPF 3.0 (5.0 for
76 tion VB)
77 WPF Class li‐ wpflib [C#], VB Common/WPF 3.0 (5.0 for
78 brary VB)
79 WPF Custom wpfcustomcon‐ [C#], VB Common/WPF 3.0 (5.0 for
80 Control Li‐ trollib VB)
81 brary
82 WPF User Con‐ wpfusercon‐ [C#], VB Common/WPF 3.0 (5.0 for
83 trol Library trollib VB)
84 Windows Forms winforms [C#], VB Common/Win‐ 3.0 (5.0 for
85 (WinForms) Forms VB)
86 Application
87 Windows Forms winformslib [C#], VB Common/Win‐ 3.0 (5.0 for
88 (WinForms) Forms VB)
89 Class library
90 Worker Ser‐ worker [C#] Common/Work‐ 3.0
91 vice er/Web
92 Unit Test mstest [C#], F#, VB Test/MSTest 1.0
93 Project
94 NUnit 3 Test nunit [C#], F#, VB Test/NUnit 2.1.400
95 Project
96 NUnit 3 Test nunit-test [C#], F#, VB Test/NUnit 2.2
97 Item
98 xUnit Test xunit [C#], F#, VB Test/xUnit 1.0
99 Project
100 Razor Compo‐ razorcompo‐ [C#] Web/ASP.NET 3.0
101 nent nent
102 Razor Page page [C#] Web/ASP.NET 2.0
103 MVC ViewIm‐ viewimports [C#] Web/ASP.NET 2.0
104 ports
105 MVC ViewStart viewstart [C#] Web/ASP.NET 2.0
106 Blazor Server blazorserver [C#] Web/Blazor 3.0
107 App
108 Blazor We‐ blazorwasm [C#] Web/Bla‐ 3.1.300
109 bAssembly App zor/WebAssem‐
110 bly
111 ASP.NET Core web [C#], F# Web/Empty 1.0
112 Empty
113 ASP.NET Core mvc [C#], F# Web/MVC 1.0
114 Web App (Mod‐
115 el-View-Con‐
116 troller)
117 ASP.NET Core webapp, razor [C#] Web/MVC/Razor 2.2, 2.0
118 Web App Pages
119 ASP.NET Core angular [C#] Web/MVC/SPA 2.0
120 with Angular
121 ASP.NET Core react [C#] Web/MVC/SPA 2.0
122 with React.js
123 ASP.NET Core reactredux [C#] Web/MVC/SPA 2.0
124 with React.js
125 and Redux
126 Razor Class razorclasslib [C#] Web/Razor/Li‐ 2.1
127 Library brary/Razor
128 Class Library
129 ASP.NET Core webapi [C#], F# Web/WebAPI 1.0
130 Web API
131
132
133 ASP.NET Core grpc [C#] Web/gRPC 3.0
134 gRPC Service
135 dotnet gitig‐ gitignore Config 3.0
136 nore file
137 global.json globaljson Config 2.0
138 file
139 NuGet Config nugetconfig Config 1.0
140 Dotnet local tool-manifest Config 3.0
141 tool manifest
142 file
143 Web Config webconfig Config 1.0
144 Solution File sln Solution 1.0
145 Protocol Buf‐ proto Web/gRPC 3.0
146 fer File
147
149 • --dry-run
150
151 Displays a summary of what would happen if the given command were run
152 if it would result in a template creation. Available since .NET Core
153 2.2 SDK.
154
155 • --force
156
157 Forces content to be generated even if it would change existing
158 files. This is required when the template chosen would override ex‐
159 isting files in the output directory.
160
161 • -?|-h|--help
162
163 Prints out help for the command. It can be invoked for the dotnet
164 new command itself or for any template. For example, dotnet new mvc
165 --help.
166
167 • -lang|--language {C#|F#|VB}
168
169 The language of the template to create. The language accepted varies
170 by the template (see defaults in the arguments section). Not valid
171 for some templates.
172
173 [!NOTE] Some shells interpret # as a special character. In
174 those cases, enclose the language parameter value in quotes.
175 For example, dotnet new console -lang "F#".
176
177 • -n|--name <OUTPUT_NAME>
178
179 The name for the created output. If no name is specified, the name
180 of the current directory is used.
181
182 • -o|--output <OUTPUT_DIRECTORY>
183
184 Location to place the generated output. The default is the current
185 directory.
186
187 Template options
188 Each template may have additional options defined. For more informa‐
189 tion, see .NET default templates for dotnet new.
190
192 • Create a C# console application project:
193
194 dotnet new console
195
196 • Create an F# console application project in the current directory:
197
198 dotnet new console --language "F#"
199
200 • Create a .NET Standard 2.0 class library project in the specified di‐
201 rectory:
202
203 dotnet new classlib --framework "netstandard2.0" -o MyLibrary
204
205 • Create a new ASP.NET Core C# MVC project in the current directory
206 with no authentication:
207
208 dotnet new mvc -au None
209
210 • Create a new xUnit project:
211
212 dotnet new xunit
213
214 • Create a global.json in the current directory setting the SDK version
215 to 3.1.101:
216
217 dotnet new globaljson --sdk-version 3.1.101
218
219 See also
220 • dotnet new –list option
221
222 • dotnet new –search option
223
224 • dotnet new –install option
225
226 • .NET default templates for dotnet new
227
228 • Custom templates for dotnet new
229
230 • Create a custom template for dotnet new
231
232 • dotnet/dotnet-template-samples GitHub repo (https://github.com/dot‐
233 net/dotnet-template-samples)
234
235
236
237 (1)