1(1) .NET (1)
2
3
4
6 This article applies to: ✔️ .NET Core 2.1 SDK and later versions
7
9 dotnet - The generic driver for the .NET CLI.
10
12 To get information about the available commands and the environment:
13
14 dotnet [--version] [--info] [--list-runtimes] [--list-sdks]
15
16 dotnet -h|--help
17
18 To run a command (requires SDK installation):
19
20 dotnet <COMMAND> [-d|--diagnostics] [-h|--help] [--verbosity <LEVEL>]
21 [command-options] [arguments]
22
23 To run an application:
24
25 dotnet [--additionalprobingpath <PATH>] [--additional-deps <PATH>]
26 [--fx-version <VERSION>] [--roll-forward <SETTING>]
27 <PATH_TO_APPLICATION> [arguments]
28
29 dotnet exec [--additionalprobingpath] [--additional-deps <PATH>]
30 [--fx-version <VERSION>] [--roll-forward <SETTING>]
31 <PATH_TO_APPLICATION> [arguments]
32
33 --roll-forward is available since .NET Core 3.x. Use --roll-forward-
34 on-no-candidate-fx for .NET Core 2.x.
35
37 The dotnet command has two functions:
38
39 • It provides commands for working with .NET projects.
40
41 For example, dotnet build builds a project. Each command defines its
42 own options and arguments. All commands support the --help option
43 for printing out brief documentation about how to use the command.
44
45 • It runs .NET applications.
46
47 You specify the path to an application .dll file to run the applica‐
48 tion. To run the application means to find and execute the entry
49 point, which in the case of console apps is the Main method. For ex‐
50 ample, dotnet myapp.dll runs the myapp application. See .NET appli‐
51 cation deployment to learn about deployment options.
52
54 Different options are available for dotnet by itself, for running a
55 command, and for running an application.
56
57 Options for dotnet by itself
58 The following options are for dotnet by itself. For example, dotnet
59 --info. They print out information about the environment.
60
61 • --info
62
63 Prints out detailed information about a .NET installation and the ma‐
64 chine environment, such as the current operating system, and commit
65 SHA of the .NET version.
66
67 • --version
68
69 Prints out the version of the .NET SDK used by dotnet commands. In‐
70 cludes the effects of any global.json
71
72 • --list-runtimes
73
74 Prints out a list of the installed .NET runtimes. An x86 version of
75 the SDK lists only x86 runtimes, and an x64 version of the SDK lists
76 only x64 runtimes.
77
78 • --list-sdks
79
80 Prints out a list of the installed .NET SDKs.
81
82 • -?|-h|--help
83
84 Prints out a list of available commands.
85
86 SDK options for running a command
87 The following options are for dotnet with a command. For example, dot‐
88 net build --help.
89
90 • -d|--diagnostics
91
92 Enables diagnostic output.
93
94 • -v|--verbosity <LEVEL>
95
96 Sets the verbosity level of the command. Allowed values are q[uiet],
97 m[inimal], n[ormal], d[etailed], and diag[nostic]. Not supported in
98 every command. See specific command page to determine if this option
99 is available.
100
101 • -?|-h|--help
102
103 Prints out documentation for a given command, such as dotnet build
104 --help.
105
106 • command options
107
108 Each command defines options specific to that command. See specific
109 command page for a list of available options.
110
111 Runtime options
112 The following options are available when dotnet runs an application.
113 For example, dotnet myapp.dll --roll-forward Major.
114
115 • --additionalprobingpath <PATH>
116
117 Path containing probing policy and assemblies to probe.
118
119 • --additional-deps <PATH>
120
121 Path to an additional .deps.json file. A deps.json file contains a
122 list of dependencies, compilation dependencies, and version informa‐
123 tion used to address assembly conflicts. For more information, see
124 Runtime Configuration Files (https://github.com/dot‐
125 net/sdk/blob/main/documentation/specs/runtime-configuration-file.md)
126 on GitHub.
127
128 • --depsfile <PATH_TO_DEPSFILE>
129
130 Path to the deps.json file. A deps.json file is a configuration file
131 that contains information about dependencies necessary to run the ap‐
132 plication. This file is generated by the .NET SDK.
133
134 • --runtimeconfig
135
136 Path to a runtimeconfig.json file. A runtimeconfig.json file is a
137 configuration file that contains run-time settings. For more infor‐
138 mation, see .NET runtime configuration settings.
139
140 • --roll-forward <SETTING> Available starting with .NET Core SDK 3.0.
141
142 Controls how roll forward is applied to the app. The SETTING can be
143 one of the following values. If not specified, Minor is the default.
144
145 • LatestPatch - Roll forward to the highest patch version. This dis‐
146 ables minor version roll forward.
147
148 • Minor - Roll forward to the lowest higher minor version, if re‐
149 quested minor version is missing. If the requested minor version
150 is present, then the LatestPatch policy is used.
151
152 • Major - Roll forward to lowest higher major version, and lowest mi‐
153 nor version, if requested major version is missing. If the re‐
154 quested major version is present, then the Minor policy is used.
155
156 • LatestMinor - Roll forward to highest minor version, even if re‐
157 quested minor version is present. Intended for component hosting
158 scenarios.
159
160 • LatestMajor - Roll forward to highest major and highest minor ver‐
161 sion, even if requested major is present. Intended for component
162 hosting scenarios.
163
164 • Disable - Don’t roll forward. Only bind to specified version.
165 This policy isn’t recommended for general use because it disables
166 the ability to roll forward to the latest patches. This value is
167 only recommended for testing.
168
169 With the exception of Disable, all settings will use the highest
170 available patch version.
171
172 Roll forward behavior can also be configured in a project file prop‐
173 erty, a runtime configuration file property, and an environment vari‐
174 able. For more information, see Major-version runtime roll forward.
175
176 • --roll-forward-on-no-candidate-fx <N> Available in .NET Core 2.x SDK.
177
178 Defines behavior when the required shared framework is not available.
179 N can be:
180
181 • 0 - Disable even minor version roll forward.
182
183 • 1 - Roll forward on minor version, but not on major version. This
184 is the default behavior.
185
186 • 2 - Roll forward on minor and major versions.
187
188 For more information, see Roll forward.
189
190 Starting with .NET Core 3.0, this option is superseded by --roll-for‐
191 ward, and that option should be used instead.
192
193 • --fx-version <VERSION>
194
195 Version of the .NET runtime to use to run the application.
196
197 This option overrides the version of the first framework reference in
198 the application’s .runtimeconfig.json file. This means it only works
199 as expected if there’s just one framework reference. If the applica‐
200 tion has more than one framework reference, using this option may
201 cause errors.
202
203 dotnet commands
204 General
205 Command Function
206 ─────────────────────────────────────────────────
207 dotnet build Builds a .NET application.
208 dotnet build-server Interacts with servers
209 started by a build.
210 dotnet clean Clean build outputs.
211 dotnet help Shows more detailed docu‐
212 mentation online for the
213 command.
214 dotnet migrate Migrates a valid Preview 2
215 project to a .NET Core SDK
216 1.0 project.
217 dotnet msbuild Provides access to the MS‐
218 Build command line.
219 dotnet new Initializes a C# or F#
220 project for a given tem‐
221 plate.
222 dotnet pack Creates a NuGet package of
223 your code.
224 dotnet publish Publishes a .NET frame‐
225 work-dependent or self-
226 contained application.
227 dotnet restore Restores the dependencies
228 for a given application.
229 dotnet run Runs the application from
230 source.
231 dotnet sdk check Shows up-to-date status of
232 installed SDK and Runtime
233 versions.
234 dotnet sln Options to add, remove,
235 and list projects in a so‐
236 lution file.
237 dotnet store Stores assemblies in the
238 runtime package store.
239 dotnet test Runs tests using a test
240 runner.
241
242 Project references
243 Command Function
244 ─────────────────────────────────────────────────────
245 dotnet add reference Adds a project reference.
246 dotnet list reference Lists project references.
247 dotnet remove reference Removes a project refer‐
248 ence.
249
250 NuGet packages
251 Command Function
252 ─────────────────────────────────────────────────
253 dotnet add package Adds a NuGet package.
254 dotnet remove package Removes a NuGet package.
255
256 NuGet commands
257 Command Function
258 ────────────────────────────────────────────────────────
259 dotnet nuget delete Deletes or unlists a pack‐
260 age from the server.
261 dotnet nuget push Pushes a package to the
262 server and publishes it.
263
264
265 dotnet nuget locals Clears or lists local
266 NuGet resources such as
267 http-request cache, tempo‐
268 rary cache, or machine-
269 wide global packages fold‐
270 er.
271 dotnet nuget add source Adds a NuGet source.
272 dotnet nuget disable Disables a NuGet source.
273 source
274 dotnet nuget enable source Enables a NuGet source.
275 dotnet nuget list source Lists all configured NuGet
276 sources.
277 dotnet nuget remove source Removes a NuGet source.
278 dotnet nuget update source Updates a NuGet source.
279
280 Workload commands
281 Command Function
282 ───────────────────────────────────────────────────────
283 dotnet workload install Installs an optional work‐
284 load.
285 dotnet workload list Lists all installed work‐
286 loads.
287 dotnet workload repair Repairs all installed
288 workloads.
289 dotnet workload search List selected workloads or
290 all available workloads.
291 dotnet workload uninstall Uninstalls a workload.
292 dotnet workload update Reinstalls all installed
293 workloads.
294
295 Global, tool-path, and local tools commands
296 Tools are console applications that are installed from NuGet packages
297 and are invoked from the command prompt. You can write tools yourself
298 or install tools written by third parties. Tools are also known as
299 global tools, tool-path tools, and local tools. For more information,
300 see .NET tools overview. Global and tool-path tools are available
301 starting with .NET Core SDK 2.1. Local tools are available starting
302 with .NET Core SDK 3.0.
303
304 Command Function
305 ───────────────────────────────────────────────────
306 dotnet tool install Installs a tool on your
307 machine.
308 dotnet tool list Lists all global, tool-
309 path, or local tools cur‐
310 rently installed on your
311 machine.
312 dotnet tool search Searches NuGet.org for
313 tools that have the speci‐
314 fied search term in their
315 name or metadata.
316 dotnet tool uninstall Uninstalls a tool from
317 your machine.
318 dotnet tool update Updates a tool that is in‐
319 stalled on your machine.
320
321 Additional tools
322 Starting with .NET Core SDK 2.1.300, a number of tools that were avail‐
323 able only on a per project basis using DotnetCliToolReference are now
324 available as part of the .NET SDK. These tools are listed in the fol‐
325 lowing table:
326
327 Tool Function
328 ──────────────────────────────────────────
329
330
331 dev-certs Creates and manages devel‐
332 opment certificates.
333 ef Entity Framework Core com‐
334 mand-line tools.
335 sql-cache SQL Server cache command-
336 line tools.
337 user-secrets Manages development user
338 secrets.
339 watch Starts a file watcher that
340 runs a command when files
341 change.
342
343 For more information about each tool, type dotnet <tool-name> --help.
344
346 Create a new .NET console application:
347
348 dotnet new console
349
350 Build a project and its dependencies in a given directory:
351
352 dotnet build
353
354 Run an application:
355
356 dotnet myapp.dll
357
358 See also
359 • Environment variables used by .NET SDK, .NET CLI, and .NET runtime
360
361 • Runtime Configuration Files (https://github.com/dot‐
362 net/sdk/blob/main/documentation/specs/runtime-configuration-file.md)
363
364 • .NET runtime configuration settings
365
366
367
368 (1)