1dotnet(1) .NET Documentation dotnet(1)
2
3
4
6 This article applies to: ✔️ .NET Core 3.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 [--depsfile <PATH>]
31 [--fx-version <VERSION>] [--roll-forward <SETTING>]
32 [--runtimeconfig <PATH>]
33 <PATH_TO_APPLICATION> [arguments]
34
36 The dotnet command has two functions:
37
38 • It provides commands for working with .NET projects.
39
40 For example, dotnet build builds a project. Each command defines its
41 own options and arguments. All commands support the --help option
42 for printing out brief documentation about how to use the command.
43
44 • It runs .NET applications.
45
46 You specify the path to an application .dll file to run the applica‐
47 tion. To run the application means to find and execute the entry
48 point, which in the case of console apps is the Main method. For ex‐
49 ample, dotnet myapp.dll runs the myapp application. See .NET appli‐
50 cation deployment to learn about deployment options.
51
53 Different options are available for:
54
55 • Displaying information about the environment.
56
57 • Running a command.
58
59 • Running an application.
60
61 Options for displaying environment information and available commands
62 The following options are available when dotnet is used by itself,
63 without specifying a command or an application to run. For example,
64 dotnet --info or dotnet --version. They print out information about
65 the environment.
66
67 • --info
68
69 Prints out detailed information about a .NET installation and the ma‐
70 chine environment, such as the current operating system, and commit
71 SHA of the .NET version.
72
73 • --version
74
75 Prints out the version of the .NET SDK used by dotnet commands, which
76 may be affected by a global.json file. Available only when the SDK is
77 installed.
78
79 • --list-runtimes
80
81 Prints out a list of the installed .NET runtimes. An x86 version of
82 the SDK lists only x86 runtimes, and an x64 version of the SDK lists
83 only x64 runtimes.
84
85 • --list-sdks
86
87 Prints out a list of the installed .NET SDKs.
88
89 • -?|-h|--help
90
91 Prints out a list of available commands.
92
93 Options for running a command
94 The following options are for dotnet with a command. For example, dot‐
95 net build --help or dotnet build --verbosity diagnostic.
96
97 • -d|--diagnostics
98
99 Enables diagnostic output.
100
101 • -v|--verbosity <LEVEL>
102
103 Sets the verbosity level of the command. Allowed values are q[uiet],
104 m[inimal], n[ormal], d[etailed], and diag[nostic]. Not supported in
105 every command. See specific command page to determine if this option
106 is available.
107
108 • -?|-h|--help
109
110 Prints out documentation for a given command. For example, dotnet
111 build --help displays help for the build command.
112
113 • command options
114
115 Each command defines options specific to that command. See specific
116 command page for a list of available options.
117
118 Options for running an application
119 The following options are available when dotnet runs an application.
120 For example, dotnet --roll-forward Major myapp.dll.
121
122 • --additionalprobingpath <PATH>
123
124 Path containing probing policy and assemblies to probe. Repeat the
125 option to specify multiple paths.
126
127 • --additional-deps <PATH>
128
129 Path to an additional .deps.json file. A deps.json file contains a
130 list of dependencies, compilation dependencies, and version informa‐
131 tion used to address assembly conflicts. For more information, see
132 Runtime Configuration Files (https://github.com/dot‐
133 net/sdk/blob/main/documentation/specs/runtime-configuration-file.md)
134 on GitHub.
135
136 • --roll-forward <SETTING> **
137
138 Controls how roll forward is applied to the app. The SETTING can be
139 one of the following values. If not specified, Minor is the default.
140
141 • LatestPatch - Roll forward to the highest patch version. This dis‐
142 ables minor version roll forward.
143
144 • Minor - Roll forward to the lowest higher minor version, if re‐
145 quested minor version is missing. If the requested minor version
146 is present, then the LatestPatch policy is used.
147
148 • Major - Roll forward to lowest higher major version, and lowest mi‐
149 nor version, if requested major version is missing. If the re‐
150 quested major version is present, then the Minor policy is used.
151
152 • LatestMinor - Roll forward to highest minor version, even if re‐
153 quested minor version is present. Intended for component hosting
154 scenarios.
155
156 • LatestMajor - Roll forward to highest major and highest minor ver‐
157 sion, even if requested major is present. Intended for component
158 hosting scenarios.
159
160 • Disable - Don’t roll forward. Only bind to specified version.
161 This policy isn’t recommended for general use because it disables
162 the ability to roll forward to the latest patches. This value is
163 only recommended for testing.
164
165 With the exception of Disable, all settings will use the highest
166 available patch version.
167
168 Roll forward behavior can also be configured in a project file prop‐
169 erty, a runtime configuration file property, and an environment vari‐
170 able. For more information, see Major-version runtime roll forward.
171
172 • --fx-version <VERSION>
173
174 Version of the .NET runtime to use to run the application.
175
176 This option overrides the version of the first framework reference in
177 the application’s .runtimeconfig.json file. This means it only works
178 as expected if there’s just one framework reference. If the applica‐
179 tion has more than one framework reference, using this option may
180 cause errors.
181
182 Options for running an application with the exec command
183 The following options are available only when dotnet runs an applica‐
184 tion by using the exec command. For example, dotnet exec --runtimecon‐
185 fig myapp.runtimeconfig.json myapp.dll.
186
187 • --depsfile <PATH>
188
189 Path to a deps.json file. A deps.json file is a configuration file
190 that contains information about dependencies necessary to run the ap‐
191 plication. This file is generated by the .NET SDK.
192
193 • --runtimeconfig <PATH>
194
195 Path to a runtimeconfig.json file. A runtimeconfig.json file con‐
196 tains run-time settings and is typically named <applicationname>.run‐
197 timeconfig.json. For more information, see .NET runtime configura‐
198 tion settings.
199
200 dotnet commands
201 General
202 Command Function
203 ─────────────────────────────────────────────────
204 dotnet build Builds a .NET application.
205 dotnet build-server Interacts with servers
206 started by a build.
207 dotnet clean Clean build outputs.
208 dotnet exec Runs a .NET application.
209 dotnet help Shows more detailed docu‐
210 mentation online for the
211 command.
212 dotnet migrate Migrates a valid Preview 2
213 project to a .NET Core SDK
214 1.0 project.
215 dotnet msbuild Provides access to the MS‐
216 Build command line.
217 dotnet new Initializes a C# or F#
218 project for a given tem‐
219 plate.
220 dotnet pack Creates a NuGet package of
221 your code.
222 dotnet publish Publishes a .NET frame‐
223 work-dependent or self-
224 contained application.
225 dotnet restore Restores the dependencies
226 for a given application.
227 dotnet run Runs the application from
228 source.
229 dotnet sdk check Shows up-to-date status of
230 installed SDK and Runtime
231 versions.
232 dotnet sln Options to add, remove,
233 and list projects in a so‐
234 lution file.
235 dotnet store Stores assemblies in the
236 runtime package store.
237 dotnet test Runs tests using a test
238 runner.
239
240 Project references
241 Command Function
242 ─────────────────────────────────────────────────────
243 dotnet add reference Adds a project reference.
244 dotnet list reference Lists project references.
245 dotnet remove reference Removes a project refer‐
246 ence.
247
248 NuGet packages
249 Command Function
250 ─────────────────────────────────────────────────
251 dotnet add package Adds a NuGet package.
252 dotnet remove package Removes a NuGet package.
253
254 NuGet commands
255 Command Function
256 ────────────────────────────────────────────────────────
257 dotnet nuget delete Deletes or unlists a pack‐
258 age from the server.
259 dotnet nuget push Pushes a package to the
260 server and publishes it.
261
262
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.
301
302 Command Function
303 ───────────────────────────────────────────────────
304 dotnet tool install Installs a tool on your
305 machine.
306 dotnet tool list Lists all global, tool-
307 path, or local tools cur‐
308 rently installed on your
309 machine.
310 dotnet tool search Searches NuGet.org for
311 tools that have the speci‐
312 fied search term in their
313 name or metadata.
314 dotnet tool uninstall Uninstalls a tool from
315 your machine.
316 dotnet tool update Updates a tool that is in‐
317 stalled on your machine.
318
319 Additional tools
320 The following additional tools are available as part of the .NET SDK:
321
322 Tool Function
323 ──────────────────────────────────────────
324 dev-certs Creates and manages devel‐
325 opment certificates.
326 ef Entity Framework Core com‐
327 mand-line tools.
328 user-secrets Manages development user
329 secrets.
330
331 watch A file watcher that
332 restarts or hot reloads an
333 application when it de‐
334 tects changes in the
335 source code.
336
337 For more information about each tool, type dotnet <tool-name> --help.
338
340 Create a new .NET console application:
341
342 dotnet new console
343
344 Build a project and its dependencies in a given directory:
345
346 dotnet build
347
348 Run an application:
349
350 dotnet exec myapp.dll
351
352 dotnet myapp.dll
353
355 • Environment variables used by .NET SDK, .NET CLI, and .NET runtime
356
357 • Runtime Configuration Files (https://github.com/dot‐
358 net/sdk/blob/main/documentation/specs/runtime-configuration-file.md)
359
360 • .NET runtime configuration settings
361
362
363
364 2022-10-10 dotnet(1)