Skip to content

Commit 5cbb513

Browse files
authored
specify behavior of dotnet run for arguments and using file option
1 parent bfacaa6 commit 5cbb513

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

docs/core/tools/dotnet-run.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ To run the application, the `dotnet run` command resolves the dependencies of th
5858
`<applicationArguments>`
5959

6060
Arguments passed to the application that is being run.
61+
62+
Any arguments that aren't recognized by `dotnet run` are passed to the application. To separate arguments for `dotnet run` from arguments for the application, use the `--` option.
6163

6264
## Options
6365

@@ -83,7 +85,7 @@ To run the application, the `dotnet run` command resolves the dependencies of th
8385

8486
- **`--file <FILE_PATH>`**
8587

86-
The path to the file-based app to run. This option can be passed as the first argument if there is no project in the current directory. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs).
88+
The path to the file-based app to run. If a path isn't specified, the current directory is used to find and run the file. For more information on file-based apps, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs).
8789

8890
On Unix, you can run file-based apps directly, using the source file name on the command line instead of `dotnet run`. First, ensure the file has execute permissions. Then, add a shebang line `#!` as the first line of the file, for example:
8991

@@ -179,10 +181,10 @@ The environment is constructed in the same order as this list, so the `-e|--envi
179181
dotnet run
180182
```
181183

182-
- Run the specified file-based app with arguments:
184+
- Run the specified file-based app in the current directory:
183185

184186
```dotnetcli
185-
dotnet run ConsoleApp.cs -- arg1 arg2
187+
dotnet run --file ConsoleApp.cs
186188
```
187189

188190
File-based app support was added in .NET SDK 10.0.100.
@@ -210,3 +212,15 @@ The environment is constructed in the same order as this list, so the `-e|--envi
210212
```dotnetcli
211213
dotnet run --verbosity m
212214
```
215+
216+
- Run the project in the current directory using the specified framework and pass arguments to the application:
217+
218+
```dotnetcli
219+
dotnet run -f net6.0 -- arg1 arg2
220+
```
221+
222+
In the following example, three arguments are passed to the application. One argument is passed using `-`, and two arguments are passed after `--`:
223+
224+
```dotnetcli
225+
dotnet run -f net6.0 -arg1 -- arg2 arg3
226+
```

includes/cli-arguments-project-solution-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.topic: include
55

66
`PROJECT | SOLUTION | FILE`
77

8-
The project or solution or C# (file-based app) file to clean. If a file isn't specified, MSBuild searches the current directory for a project or solution.
8+
The project or solution or C# (file-based app) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution.
99

1010
- `PROJECT` is the path and filename of a C#, F#, or Visual Basic project file, or the path to a directory that contains a C#, F#, or Visual Basic project file.
1111

0 commit comments

Comments
 (0)