Skip to content

Commit 1bef173

Browse files
authored
Add missing details to run-file spec (#52085)
1 parent ce90906 commit 1bef173

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

documentation/general/dotnet-run-file.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Additionally, the implicit project file has the following customizations:
3232

3333
- `PublishAot` is set to `true`, see [`dotnet publish file.cs`](#other-commands) for more details.
3434

35+
- `PackAsTool` is set to `true`, see [`dotnet pack file.cs`](#other-commands) for more details.
36+
3537
- `UserSecretsId` is set to a hash of the entry point file path.
3638

3739
- [File-level directives](#directives-for-project-metadata) are applied.
@@ -103,7 +105,10 @@ If a dash (`-`) is given instead of the target path (i.e., `dotnet run -`), the
103105
In this case, the current working directory is not used to search for other files (launch profiles, other sources in case of multi-file apps);
104106
the compilation consists solely of the single file read from the standard input.
105107

106-
`dotnet path.cs` is a shortcut for `dotnet run --file path.cs` provided that `path.cs` is a valid [target path](#target-path) (`dotnet -` is currently not supported).
108+
`dotnet path.cs` is a shortcut for `dotnet run --file path.cs` provided that `path.cs` is a valid [target path](#target-path) (`dotnet -` is currently not supported)
109+
and it is not a DLL path, built-in command, or a NuGet tool (e.g., `dotnet watch` invokes the `dotnet-watch` tool
110+
even if a valid `watch` file-based app exists in the current directory;
111+
one can use `dotnet ./watch` to run the file-based app).
107112

108113
### Other commands
109114

@@ -112,6 +117,8 @@ Commands `dotnet restore file.cs` and `dotnet build file.cs` are needed for IDE
112117
Commands `dotnet publish file.cs` and `dotnet pack file.cs` are also supported for file-based programs.
113118
Note that file-based apps have implicitly set `PublishAot=true`, so publishing uses Native AOT (and building reports AOT warnings).
114119
To opt out, use `#:property PublishAot=false` directive in your `.cs` file.
120+
Additionally, file-based apps have implicitly set `PackAsTool=true` because file-based apps are usually tools;
121+
again, you can opt out via `#:property PackAsTool=false`.
115122

116123
Command `dotnet clean file.cs` can be used to clean build artifacts of the file-based program.
117124

0 commit comments

Comments
 (0)