1(1)                                  .NET                                  (1)
2
3
4

dotnet run

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

NAME

9       dotnet  run  -  Runs source code without any explicit compile or launch
10       commands.
11

SYNOPSIS

13              dotnet run [-a|--arch <ARCHITECTURE>] [-c|--configuration <CONFIGURATION>]
14                  [-f|--framework <FRAMEWORK>] [--force] [--interactive]
15                  [--launch-profile <NAME>] [--no-build]
16                  [--no-dependencies] [--no-launch-profile] [--no-restore]
17                  [--os <OS>] [--project <PATH>] [-r|--runtime <RUNTIME_IDENTIFIER>]
18                  [-v|--verbosity <LEVEL>] [[--] [application arguments]]
19
20              dotnet run -h|--help
21

DESCRIPTION

23       The dotnet run command provides a convenient option to run your  appli‐
24       cation from the source code with one command.  It’s useful for fast it‐
25       erative development from the command line.  The command depends on  the
26       dotnet  build  command  to  build  the  code.  Any requirements for the
27       build, such as that the project must be restored first, apply to dotnet
28       run as well.
29
30              [!NOTE]  dotnet  run  doesn’t  respect  arguments  like /proper‐
31              ty:property=value, which are respected by dotnet build.
32
33       Output files are written into the default location, which is  bin/<con‐
34       figuration>/<target>.  For example if you have a netcoreapp2.1 applica‐
35       tion and you run dotnet run, the output is placed in bin/Debug/netcore‐
36       app2.1.   Files  are overwritten as needed.  Temporary files are placed
37       in the obj directory.
38
39       If the project specifies multiple frameworks, executing dotnet run  re‐
40       sults  in an error unless the -f|--framework <FRAMEWORK> option is used
41       to specify the framework.
42
43       The dotnet run command is used in the context of  projects,  not  built
44       assemblies.   If you’re trying to run a framework-dependent application
45       DLL instead, you must use dotnet without a command.   For  example,  to
46       run myapp.dll, use:
47
48              dotnet myapp.dll
49
50       For  more  information  on the dotnet driver, see the .NET Command Line
51       Tools (CLI) topic.
52
53       To run the application, the dotnet run command resolves  the  dependen‐
54       cies of the application that are outside of the shared runtime from the
55       NuGet cache.  Because it uses cached dependencies, it’s not recommended
56       to use dotnet run to run applications in production.  Instead, create a
57       deployment using the dotnet publish command and  deploy  the  published
58       output.
59
60   Implicit restore
61       You don’t have to run dotnet restore because it’s run implicitly by all
62       commands that require a restore to occur, such as  dotnet  new,  dotnet
63       build,  dotnet  run,  dotnet test, dotnet publish, and dotnet pack.  To
64       disable implicit restore, use the --no-restore option.
65
66       The dotnet restore command is still useful in certain  scenarios  where
67       explicitly restoring makes sense, such as continuous integration builds
68       in Azure DevOps Services or in build systems that  need  to  explicitly
69       control when the restore occurs.
70
71       For information about how to manage NuGet feeds, see the dotnet restore
72       documentation.
73
74       This command supports the dotnet restore options  when  passed  in  the
75       long form (for example, --source).  Short form options, such as -s, are
76       not supported.
77
78   Workload manifest downloads
79       When you run this command,  it  initiates  an  asynchronous  background
80       download  of  advertising  manifests for workloads.  If the download is
81       still running when this command finishes, the download is stopped.  For
82       more information, see Advertising manifests.
83

OPTIONS

85--
86
87         Delimits  arguments  to dotnet run from arguments for the application
88         being run.  All arguments after this delimiter are passed to the  ap‐
89         plication run.
90
91-a|--arch <ARCHITECTURE>
92
93         Specifies  the  target  architecture.  This is a shorthand syntax for
94         setting the Runtime Identifier (RID), where  the  provided  value  is
95         combined  with  the  default RID.  For example, on a win-x64 machine,
96         specifying --arch x86 sets the RID to win-x86.  If you use  this  op‐
97         tion, don’t use the -r|--runtime option.  Available since .NET 6 Pre‐
98         view 7.
99
100-c|--configuration <CONFIGURATION>
101
102         Defines the build configuration.  The default for  most  projects  is
103         Debug,  but you can override the build configuration settings in your
104         project.
105
106-f|--framework <FRAMEWORK>
107
108         Builds and runs the app using the specified framework.  The framework
109         must be specified in the project file.
110
111--force
112
113         Forces  all  dependencies to be resolved even if the last restore was
114         successful.  Specifying  this  flag  is  the  same  as  deleting  the
115         project.assets.json file.
116
117-?|-h|--help
118
119         Prints out a description of how to use the command.
120
121--interactive
122
123         Allows  the  command  to stop and wait for user input or action.  For
124         example, to complete authentication.  Available since .NET  Core  3.0
125         SDK.
126
127--launch-profile <NAME>
128
129         The name of the launch profile (if any) to use when launching the ap‐
130         plication.  Launch profiles are defined  in  the  launchSettings.json
131         file  and  are typically called Development, Staging, and Production.
132         For more information, see Working with multiple environments.
133
134--no-build
135
136         Doesn’t build the project before running.  It also implicit sets  the
137         --no-restore flag.
138
139--no-dependencies
140
141         When  restoring  a  project with project-to-project (P2P) references,
142         restores the root project and not the references.
143
144--no-launch-profile
145
146         Doesn’t try to use launchSettings.json to configure the application.
147
148--no-restore
149
150         Doesn’t execute an implicit restore when running the command.
151
152--os <OS>
153
154         Specifies the target operating system (OS).  This is a shorthand syn‐
155         tax for setting the Runtime Identifier (RID), where the provided val‐
156         ue is combined with the default RID.  For example, on a  win-x64  ma‐
157         chine,  specifying  --os  os sets the RID to os-x64.  If you use this
158         option, don’t use the -r|--runtime option.  Available  since  .NET  6
159         Preview 7.
160
161--project <PATH>
162
163         Specifies  the  path  of the project file to run (folder name or full
164         path).  If not specified, it defaults to the current directory.
165
166         The -p abbreviation for --project is deprecated starting  in  .NET  6
167         Preview  SDK.   For a limited time starting in .NET 6 RC1 SDK, -p can
168         still be used for --project despite the deprecation warning.  If  the
169         argument  provided  for the option doesn’t contain =, the command ac‐
170         cepts -p as short for --project.  Otherwise, the command assumes that
171         -p  is  short  for --property.  This flexible use of -p for --project
172         will be phased out in .NET 7.
173
174--property:<NAME>=<VALUE>
175
176         Sets one or more MSBuild properties.  Specify multiple properties de‐
177         limited by semicolons or by repeating the option:
178
179                --property:<NAME1>=<VALUE1>;<NAME2>=<VALUE2>
180                --property:<NAME1>=<VALUE1> --property:<NAME2>=<VALUE2>
181
182         The  short  form -p can be used for --property.  If the argument pro‐
183         vided for the option contains =, -p is accepted as short for  --prop‐
184         erty.  Otherwise, the command assumes that -p is short for --project.
185
186         To  pass  --property  to  the  application rather than set an MSBuild
187         property, provide the option after the -- syntax separator, for exam‐
188         ple:
189
190                dotnet run -- --property name=value
191
192-r|--runtime <RUNTIME_IDENTIFIER>
193
194         Specifies  the target runtime to restore packages for.  For a list of
195         Runtime Identifiers (RIDs), see the RID  catalog.   -r  short  option
196         available since .NET Core 3.0 SDK.
197
198-v|--verbosity <LEVEL>
199
200         Sets the verbosity level of the command.  Allowed values are q[uiet],
201         m[inimal], n[ormal], d[etailed], and diag[nostic].   The  default  is
202         minimal.   For  more  information,  see  <xref:Microsoft.Build.Frame‐
203         work.LoggerVerbosity>.
204

EXAMPLES

206       • Run the project in the current directory:
207
208                dotnet run
209
210       • Run the specified project:
211
212                dotnet run --project ./projects/proj1/proj1.csproj
213
214       • Run the project in the current directory, specifying Release configu‐
215         ration:
216
217                dotnet run --property:Configuration=Release
218
219       • Run the project in the current directory (the --help argument in this
220         example is passed to the application, since the blank  --  option  is
221         used):
222
223                dotnet run --configuration Release -- --help
224
225       • Restore  dependencies and tools for the project in the current direc‐
226         tory only showing minimal output and then run the project:
227
228                dotnet run --verbosity m
229
230
231
232                                                                           (1)
Impressum