From 99072086fe37e0df18f55fb5ffbe8c6b6829394e Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 09:20:21 -0700 Subject: [PATCH 01/14] add file based changes for dotnet build --- docs/core/tools/dotnet-build.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index bbd05214f6a38..a17294c1c247e 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -1,11 +1,11 @@ --- title: dotnet build command description: The dotnet build command builds a project and all of its dependencies. -ms.date: 11/27/2023 +ms.date: 09/24/2025 --- # dotnet build -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ .NET 6 and later versions ## Name @@ -14,7 +14,7 @@ ms.date: 11/27/2023 ## Synopsis ```dotnetcli -dotnet build [|] [-a|--arch ] +dotnet build [||] [-a|--arch ] [--artifacts-path ] [-c|--configuration ] [-f|--framework ] [--disable-build-servers] @@ -23,7 +23,7 @@ dotnet build [|] [-a|--arch ] [-o|--output ] [-p|--property:=] [-r|--runtime ] - [--self-contained [true|false]] [--source ] + [-sc|--self-contained [true|false]] [--source ] [--tl:[auto|on|off]] [--use-current-runtime, --ucr [true|false]] [-v|--verbosity ] [--version-suffix ] @@ -77,9 +77,9 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev ## Arguments -`PROJECT | SOLUTION` +`PROJECT | SOLUTION | FILE` -The project or solution file to build. If a project or solution file isn't specified, MSBuild searches the current working directory for a file that has a file extension that ends in either *proj* or *sln* and uses that file. +The project or solution or C# (file-based program) file to build. If a file isn't specified, MSBuild searches the current directory for a project or solution. ## Options @@ -176,6 +176,12 @@ The project or solution file to build. If a project or solution file isn't speci dotnet build ``` +- Build a specific project file: + + ```dotnetcli + dotnet build MyProject.cs + ``` + - Build a project and its dependencies using Release configuration: ```dotnetcli From e5be715a4e2842eb065ff1ea37290dd4ecb3b964 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 09:28:36 -0700 Subject: [PATCH 02/14] add file based command for dotnet clean --- docs/core/tools/dotnet-clean.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/core/tools/dotnet-clean.md b/docs/core/tools/dotnet-clean.md index 912e73e70ab15..c7668222b5d93 100644 --- a/docs/core/tools/dotnet-clean.md +++ b/docs/core/tools/dotnet-clean.md @@ -1,11 +1,11 @@ --- title: dotnet clean command description: The dotnet clean command cleans the current directory. -ms.date: 02/14/2020 +ms.date: 09/23/2025 --- # dotnet clean -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ .NET 6 and later versions ## Name @@ -14,7 +14,7 @@ ms.date: 02/14/2020 ## Synopsis ```dotnetcli -dotnet clean [|] [--artifacts-path ] +dotnet clean [||] [--artifacts-path ] [-c|--configuration ] [-f|--framework ] [--interactive] [--nologo] [-o|--output ] @@ -30,9 +30,9 @@ The `dotnet clean` command cleans the output of the previous build. It's impleme ## Arguments -`PROJECT | SOLUTION` +`PROJECT | SOLUTION | FILE` -The MSBuild project or solution to clean. If a project or solution file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in *proj* or *sln*, and uses that file. +The project or solution or C# (file-based program) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution. ## Options @@ -76,6 +76,12 @@ The MSBuild project or solution to clean. If a project or solution file is not s dotnet clean ``` +* Clean a project in a specified file: + + ```dotnetcli + dotnet clean Program.cs. + ``` + * Clean a project built using the Release configuration: ```dotnetcli From b0fa1691b8238d6aac865ea95bc9e5785f116d1e Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 10:21:19 -0700 Subject: [PATCH 03/14] add file-based app options for dotnet-run --- docs/core/tools/dotnet-run.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index 120c3c285e564..0d5b385857cb8 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -1,11 +1,11 @@ --- title: dotnet run command description: The dotnet run command provides a convenient option to run your application from the source code. -ms.date: 03/26/2025 +ms.date: 09/24/2025 --- # dotnet run -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ .NET Core 6 and later versions ## Name @@ -14,7 +14,7 @@ ms.date: 03/26/2025 ## Synopsis ```dotnetcli -dotnet run [-a|--arch ] [-c|--configuration ] +dotnet run [] [-a|--arch ] [-c|--configuration ] [-e|--environment ] [-f|--framework ] [--force] [--interactive] [--launch-profile ] [--no-build] @@ -53,6 +53,12 @@ To run the application, the `dotnet run` command resolves the dependencies of th [!INCLUDE [cli-advertising-manifests](../../../includes/cli-advertising-manifests.md)] +## Arguments + + `` + + Arguments passed to the application that is being run. + ## Options - **`--`** @@ -75,6 +81,10 @@ To run the application, the `dotnet run` command resolves the dependencies of th Builds and runs the app using the specified [framework](../../standard/frameworks.md). The framework must be specified in the project file. +- **`--file `** + + 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. + - **`--force`** Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the *project.assets.json* file. @@ -155,6 +165,12 @@ The environment is constructed in the same order as this list, so the `-e|--envi dotnet run ``` +- Run the specified file-based app: + + ```dotnetcli + dotnet run ConsoleApp.cs -- arg1 arg2 + ``` + - Run the specified project: ```dotnetcli From bc4764f33d90f787b7eaddb127688263cfeba8ba Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 11:29:00 -0700 Subject: [PATCH 04/14] add file-based app details for dotnet publish --- docs/core/tools/dotnet-publish.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 94ffde8e5747a..57cb34ccdb64e 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -1,11 +1,11 @@ --- title: dotnet publish command description: The dotnet publish command publishes a .NET project or solution to a directory. -ms.date: 01/07/2025 +ms.date: 09/24/2025 --- # dotnet publish -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ .NET 6 and later versions ## Name @@ -14,7 +14,7 @@ ms.date: 01/07/2025 ## Synopsis ```dotnetcli -dotnet publish [|] [-a|--arch ] +dotnet publish [||] [-a|--arch ] [--artifacts-path ] [-c|--configuration ] [--disable-build-servers] [-f|--framework ] [--force] [--interactive] @@ -114,14 +114,16 @@ For more information, see the following resources: ## Arguments -- **`PROJECT|SOLUTION`** +`PROJECT | SOLUTION | FILE` - The project or solution to publish. + The project or solution or C# (file-based program) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution. * `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. If the directory is not specified, it defaults to the current directory. * `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. + * `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). + ## Options [!INCLUDE [arch](../../../includes/cli-arch.md)] @@ -268,6 +270,12 @@ For more information, see the following resources: dotnet publish --no-dependencies ``` +- Publish the file-based C# program *app.cs* in the current directory: + + ```dotnetcli + dotnet publish app.cs + ``` + ## See also - [.NET application publishing overview](../deploying/index.md) From 4f759b3a449490a9326e9c55268e59904510a748 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 11:34:56 -0700 Subject: [PATCH 05/14] add file-based app info for dotnet-restore --- docs/core/tools/dotnet-restore.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index 260800790a7f6..57586a50a423e 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -1,11 +1,11 @@ --- title: dotnet restore command description: Learn how to restore dependencies and project-specific tools with the dotnet restore command. -ms.date: 07/19/2023 +ms.date: 09/24/2025 --- # dotnet restore -**This article applies to:** ✔️ .NET Core 3.1 SDK and later versions +**This article applies to:** ✔️ .NET 6 and later versions ## Name @@ -14,7 +14,7 @@ ms.date: 07/19/2023 ## Synopsis ```dotnetcli -dotnet restore [] [--configfile ] [--disable-build-servers] +dotnet restore [||] [--configfile ] [--disable-build-servers] [--disable-parallel] [-f|--force] [--force-evaluate] [--ignore-failed-sources] [--interactive] [--lock-file-path ] [--locked-mode] @@ -86,9 +86,15 @@ There are three specific settings that `dotnet restore` ignores: ## Arguments -- **`ROOT`** +`PROJECT | SOLUTION | FILE` - Optional path to the project file to restore. + The project or solution or C# (file-based program) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. + + * `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. If the directory is not specified, it defaults to the current directory. + + * `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. + + * `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options From 0b0d495b77c3ccd732a985fb64145d20f170a6dc Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 11:42:06 -0700 Subject: [PATCH 06/14] Fix indentation --- docs/core/tools/dotnet-publish.md | 8 ++++---- docs/core/tools/dotnet-restore.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 57cb34ccdb64e..4406d9cf2fe2b 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -116,13 +116,13 @@ For more information, see the following resources: `PROJECT | SOLUTION | FILE` - The project or solution or C# (file-based program) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based program) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution. - * `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. If the directory is not specified, it defaults to the current directory. +* `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. If the directory is not specified, it defaults to the current directory. - * `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. +* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. - * `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +* `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index 57586a50a423e..b154f71586bfe 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -88,13 +88,13 @@ There are three specific settings that `dotnet restore` ignores: `PROJECT | SOLUTION | FILE` - The project or solution or C# (file-based program) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based program) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. - * `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. If the directory is not specified, it defaults to the current directory. +* `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. If the directory is not specified, it defaults to the current directory. - * `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. +* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. - * `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +* `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options From c8f1b3400f029f946daa9412f49df376f83b469f Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 14:19:49 -0700 Subject: [PATCH 07/14] add in file command --- docs/core/tools/dotnet-run.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index 0d5b385857cb8..db0dd3fcd9b49 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -5,7 +5,7 @@ ms.date: 09/24/2025 --- # dotnet run -**This article applies to:** ✔️ .NET Core 6 and later versions +**This article applies to:** ✔️ .NET 6 and later versions ## Name @@ -15,7 +15,7 @@ ms.date: 09/24/2025 ```dotnetcli dotnet run [] [-a|--arch ] [-c|--configuration ] - [-e|--environment ] + [-e|--environment ] [--file ] [-f|--framework ] [--force] [--interactive] [--launch-profile ] [--no-build] [--no-dependencies] [--no-launch-profile] [--no-restore] @@ -83,7 +83,7 @@ To run the application, the `dotnet run` command resolves the dependencies of th - **`--file `** - 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. + The path to the file-based program 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# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). - **`--force`** @@ -165,7 +165,7 @@ The environment is constructed in the same order as this list, so the `-e|--envi dotnet run ``` -- Run the specified file-based app: +- Run the specified file-based program with arguments: ```dotnetcli dotnet run ConsoleApp.cs -- arg1 arg2 From d5fe4941d755d53406304ab50acc695a37cbabdd Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 14:23:04 -0700 Subject: [PATCH 08/14] make consistency edits across commands --- docs/core/tools/dotnet-build.md | 20 ++++++++++++-------- docs/core/tools/dotnet-clean.md | 12 +++++++++--- docs/core/tools/dotnet-publish.md | 14 ++++---------- docs/core/tools/dotnet-restore.md | 2 +- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index a17294c1c247e..88722907cca39 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -9,7 +9,7 @@ ms.date: 09/24/2025 ## Name -`dotnet build` - Builds a project and all of its dependencies. +`dotnet build` - Builds a project, solution, or file-based program and all of its dependencies. ## Synopsis @@ -32,16 +32,14 @@ dotnet build -h|--help ## Description -The `dotnet build` command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a *.dll* extension. Depending on the project type and settings, other files may be included, such as: +The `dotnet build` command builds the project, solution, or file-based program and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a *.dll* extension. Depending on the project type and settings, other files may be included, such as: -- An executable that can be used to run the application, if the project type is an executable targeting .NET Core 3.0 or later. +- An executable that can be used to run the application. - Symbol files used for debugging with a *.pdb* extension. - A *.deps.json* file, which lists the dependencies of the application or library. - A *.runtimeconfig.json* file, which specifies the shared runtime and its version for an application. - Other libraries that the project depends on (via project references or NuGet package references). -For executable projects targeting versions earlier than .NET Core 3.0, library dependencies from NuGet are typically NOT copied to the output folder. They're resolved from the NuGet global packages folder at run time. With that in mind, the product of `dotnet build` isn't ready to be transferred to another machine to run. To create a version of the application that can be deployed, you need to publish it (for example, with the [dotnet publish](dotnet-publish.md) command). For more information, see [.NET Application Deployment](../deploying/index.md). - For executable projects targeting .NET Core 3.0 and later, library dependencies are copied to the output folder. This means that if there isn't any other publish-specific logic (such as Web projects have), the build output should be deployable. ### Implicit restore @@ -64,7 +62,7 @@ To produce a library, omit the `` property or change its value to `L ### MSBuild -`dotnet build` uses MSBuild to build the project, so it supports both parallel and incremental builds. For more information, see [Incremental Builds](/visualstudio/msbuild/incremental-builds). +`dotnet build` uses MSBuild to build the project, solution, or file-based program. It supports both parallel and incremental builds. For more information, see [Incremental Builds](/visualstudio/msbuild/incremental-builds). In addition to its options, the `dotnet build` command accepts MSBuild options, such as `-p` for setting properties or `-l` to define a logger. For more information about these options, see the [MSBuild Command-Line Reference](/visualstudio/msbuild/msbuild-command-line-reference). Or you can also use the [dotnet msbuild](dotnet-msbuild.md) command. @@ -79,7 +77,13 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev `PROJECT | SOLUTION | FILE` -The project or solution or C# (file-based program) file to build. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. + +* `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. + +* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. + +* `FILE` is the path and filename of a file-based program. Files-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -176,7 +180,7 @@ The project or solution or C# (file-based program) file to build. If a file isn' dotnet build ``` -- Build a specific project file: +- Build a file-based program: ```dotnetcli dotnet build MyProject.cs diff --git a/docs/core/tools/dotnet-clean.md b/docs/core/tools/dotnet-clean.md index c7668222b5d93..609c11909c9d4 100644 --- a/docs/core/tools/dotnet-clean.md +++ b/docs/core/tools/dotnet-clean.md @@ -1,7 +1,7 @@ --- title: dotnet clean command description: The dotnet clean command cleans the current directory. -ms.date: 09/23/2025 +ms.date: 09/24/2025 --- # dotnet clean @@ -32,7 +32,13 @@ The `dotnet clean` command cleans the output of the previous build. It's impleme `PROJECT | SOLUTION | FILE` -The project or solution or C# (file-based program) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. + +* `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. + +* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. + +* `FILE` is the path and filename of a file-based program. Files-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -76,7 +82,7 @@ The project or solution or C# (file-based program) file to operate on. If a file dotnet clean ``` -* Clean a project in a specified file: +* Clean a file-based program: ```dotnetcli dotnet clean Program.cs. diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 4406d9cf2fe2b..75210d05bc7f1 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -116,13 +116,13 @@ For more information, see the following resources: `PROJECT | SOLUTION | FILE` -The project or solution or C# (file-based program) file to operate on. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. -* `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. If the directory is not specified, it defaults to the current directory. +* `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. -* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. +* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -* `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +* `FILE` is the path and filename of a file-based program. Files-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -188,12 +188,6 @@ The project or solution or C# (file-based program) file to operate on. If a file If you specify a relative path when publishing a solution, all output for all projects goes into the specified folder relative to the current working directory. To make publish output go to separate folders for each project, specify a relative path by using the msbuild `PublishDir` property instead of the `--output` option. For example, `dotnet publish -p:PublishDir=.\publish` sends publish output for each project to a `publish` folder under the folder that contains the project file. - - .NET Core 2.x SDK - - If you specify a relative path when publishing a project, the generated output directory is relative to the project file location, not to the current working directory. - - If you specify a relative path when publishing a solution, each project's output goes into a separate folder relative to the project file location. If you specify an absolute path when publishing a solution, all publish output for all projects goes into the specified folder. - [!INCLUDE [os](../../../includes/cli-os.md)] - **`--sc|--self-contained [true|false]`** diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index b154f71586bfe..13723d950c4b0 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -94,7 +94,7 @@ The project or solution or C# (file-based program) file to restore. If a file is * `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. -* `FILE` is the path and filename of a file-based app. Files-based apps are programs contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +* `FILE` is the path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options From 3937765a0c4d34596d1257436c48f9028565aa63 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Wed, 24 Sep 2025 21:26:30 -0700 Subject: [PATCH 09/14] Specify the version file-based programs are available in. --- docs/core/tools/dotnet-build.md | 10 ++++++---- docs/core/tools/dotnet-clean.md | 22 ++++++++++++---------- docs/core/tools/dotnet-publish.md | 8 +++++--- docs/core/tools/dotnet-restore.md | 12 ++++++------ docs/core/tools/dotnet-run.md | 4 ++++ 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index 88722907cca39..ff925e3ef8493 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -79,11 +79,11 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. -* `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. +- `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. -* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. +- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -* `FILE` is the path and filename of a file-based program. Files-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -184,7 +184,9 @@ The project or solution or C# (file-based program) file to publish. If a file is ```dotnetcli dotnet build MyProject.cs - ``` + ``` + + File-based program support was added in .NET SDK 10.0.100. - Build a project and its dependencies using Release configuration: diff --git a/docs/core/tools/dotnet-clean.md b/docs/core/tools/dotnet-clean.md index 609c11909c9d4..71a9b3190ea61 100644 --- a/docs/core/tools/dotnet-clean.md +++ b/docs/core/tools/dotnet-clean.md @@ -34,11 +34,11 @@ The `dotnet clean` command cleans the output of the previous build. It's impleme The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. -* `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. +- `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. -* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. +- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -* `FILE` is the path and filename of a file-based program. Files-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -46,7 +46,7 @@ The project or solution or C# (file-based program) file to publish. If a file is [!INCLUDE [configuration](../../../includes/cli-configuration-clean.md)] -* **`-f|--framework `** +- **`-f|--framework `** The [framework](../../standard/frameworks.md) that was specified at build time. The framework must be defined in the [project file](../project-sdk/overview.md). If you specified the framework at build time, you must specify the framework when cleaning. @@ -54,11 +54,11 @@ The project or solution or C# (file-based program) file to publish. If a file is [!INCLUDE [interactive](../../../includes/cli-interactive-3-0.md)] -* **`--nologo`** +- **`--nologo`** Doesn't display the startup banner or the copyright message. -* **`-o|--output `** +- **`-o|--output `** The directory that contains the build artifacts to clean. Specify the `-f|--framework ` switch with the output directory switch if you specified the framework when the project was built. @@ -66,7 +66,7 @@ The project or solution or C# (file-based program) file to publish. If a file is If you specify the `--output` option when running this command on a solution, the CLI will emit a warning (an error in 7.0.200) due to the unclear semantics of the output path. The `--output` option is disallowed because all outputs of all built projects would be copied into the specified directory, which isn't compatible with multi-targeted projects, as well as projects that have different versions of direct and transitive dependencies. For more information, see [Solution-level `--output` option no longer valid for build-related commands](../compatibility/sdk/7.0/solution-level-output-no-longer-valid.md). -* **`-r|--runtime `** +- **`-r|--runtime `** Cleans the output folder of the specified runtime. This is used when a [self-contained deployment](../deploying/index.md#self-contained-deployment) was created. @@ -76,19 +76,21 @@ The project or solution or C# (file-based program) file to publish. If a file is ## Examples -* Clean a default build of the project: +- Clean a default build of the project: ```dotnetcli dotnet clean ``` -* Clean a file-based program: +- Clean a file-based program: ```dotnetcli dotnet clean Program.cs. ``` -* Clean a project built using the Release configuration: + File-based program support was added in .NET SDK 10.0.100. + +- Clean a project built using the Release configuration: ```dotnetcli dotnet clean --configuration Release diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 75210d05bc7f1..0fbfc9050cd53 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -118,11 +118,11 @@ For more information, see the following resources: The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. -* `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. +- `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. -* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. +- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -* `FILE` is the path and filename of a file-based program. Files-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -270,6 +270,8 @@ The project or solution or C# (file-based program) file to publish. If a file is dotnet publish app.cs ``` + File-based program support was added in .NET SDK 10.0.100. + ## See also - [.NET application publishing overview](../deploying/index.md) diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index 13723d950c4b0..931e618af8827 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -90,11 +90,11 @@ There are three specific settings that `dotnet restore` ignores: The project or solution or C# (file-based program) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. -* `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. If the directory is not specified, it defaults to the current directory. +- `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. If the directory is not specified, it defaults to the current directory. -* `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. +- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. -* `FILE` is the path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -190,19 +190,19 @@ The project or solution or C# (file-based program) file to restore. If a file is dotnet restore ./projects/app1/app1.csproj ``` -- Restore the dependencies and tools for the project in the current directory using the file path provided as the source: +- Restore the dependencies and tools for the project in the current directory using the file path provided as the source: ```dotnetcli dotnet restore -s c:\packages\mypackages ``` -- Restore the dependencies and tools for the project in the current directory using the two file paths provided as sources: +- Restore the dependencies and tools for the project in the current directory using the two file paths provided as sources: ```dotnetcli dotnet restore -s c:\packages\mypackages -s c:\packages\myotherpackages ``` -- Restore dependencies and tools for the project in the current directory showing detailed output: +- Restore dependencies and tools for the project in the current directory showing detailed output: ```dotnetcli dotnet restore --verbosity detailed diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index db0dd3fcd9b49..5f9384b7dd26e 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -85,6 +85,8 @@ To run the application, the `dotnet run` command resolves the dependencies of th The path to the file-based program 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# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). + Introduced in .NET SDK 10.0.100. + - **`--force`** Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the *project.assets.json* file. @@ -171,6 +173,8 @@ The environment is constructed in the same order as this list, so the `-e|--envi dotnet run ConsoleApp.cs -- arg1 arg2 ``` + File-based program support was added in .NET SDK 10.0.100. + - Run the specified project: ```dotnetcli From a2ef142cecd887e2f0f1aaa9284209ec3446dbc7 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Thu, 25 Sep 2025 09:45:52 -0700 Subject: [PATCH 10/14] apply changes from review feedback --- docs/core/tools/dotnet-build.md | 14 +++++++------- docs/core/tools/dotnet-clean.md | 6 +++--- docs/core/tools/dotnet-publish.md | 2 +- docs/core/tools/dotnet-restore.md | 4 ++-- docs/core/tools/dotnet-run.md | 18 +++++++++++++++--- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index ff925e3ef8493..a3dae67450788 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -9,7 +9,7 @@ ms.date: 09/24/2025 ## Name -`dotnet build` - Builds a project, solution, or file-based program and all of its dependencies. +`dotnet build` - Builds a project, solution, or file-based app and all of its dependencies. ## Synopsis @@ -32,7 +32,7 @@ dotnet build -h|--help ## Description -The `dotnet build` command builds the project, solution, or file-based program and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a *.dll* extension. Depending on the project type and settings, other files may be included, such as: +The `dotnet build` command builds the project, solution, or file-based app and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a *.dll* extension. Depending on the project type and settings, other files may be included, such as: - An executable that can be used to run the application. - Symbol files used for debugging with a *.pdb* extension. @@ -62,7 +62,7 @@ To produce a library, omit the `` property or change its value to `L ### MSBuild -`dotnet build` uses MSBuild to build the project, solution, or file-based program. It supports both parallel and incremental builds. For more information, see [Incremental Builds](/visualstudio/msbuild/incremental-builds). +`dotnet build` uses MSBuild to build the project, solution, or file-based app. It supports both parallel and incremental builds. For more information, see [Incremental Builds](/visualstudio/msbuild/incremental-builds). In addition to its options, the `dotnet build` command accepts MSBuild options, such as `-p` for setting properties or `-l` to define a logger. For more information about these options, see the [MSBuild Command-Line Reference](/visualstudio/msbuild/msbuild-command-line-reference). Or you can also use the [dotnet msbuild](dotnet-msbuild.md) command. @@ -77,13 +77,13 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev `PROJECT | SOLUTION | FILE` -The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based app) file to build. If a file isn't specified, MSBuild searches the current directory for a project or solution. - `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. - `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -180,13 +180,13 @@ The project or solution or C# (file-based program) file to publish. If a file is dotnet build ``` -- Build a file-based program: +- Build a file-based app: ```dotnetcli dotnet build MyProject.cs ``` - File-based program support was added in .NET SDK 10.0.100. + File-based app support was added in .NET SDK 10.0.100. - Build a project and its dependencies using Release configuration: diff --git a/docs/core/tools/dotnet-clean.md b/docs/core/tools/dotnet-clean.md index 71a9b3190ea61..e2ed7dddcf2fa 100644 --- a/docs/core/tools/dotnet-clean.md +++ b/docs/core/tools/dotnet-clean.md @@ -32,13 +32,13 @@ The `dotnet clean` command cleans the output of the previous build. It's impleme `PROJECT | SOLUTION | FILE` -The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. +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. - `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. - `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options @@ -88,7 +88,7 @@ The project or solution or C# (file-based program) file to publish. If a file is dotnet clean Program.cs. ``` - File-based program support was added in .NET SDK 10.0.100. + File-based app support was added in .NET SDK 10.0.100. - Clean a project built using the Release configuration: diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 0fbfc9050cd53..073a1a054d05f 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -122,7 +122,7 @@ The project or solution or C# (file-based program) file to publish. If a file is - `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index 931e618af8827..600a6931eff59 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -88,13 +88,13 @@ There are three specific settings that `dotnet restore` ignores: `PROJECT | SOLUTION | FILE` -The project or solution or C# (file-based program) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. +The project or solution or C# (file-based app) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. - `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. If the directory is not specified, it defaults to the current directory. - `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. -- `FILE` is an argument added in .NET 10. The path and filename of a file-based program. File-based programs are contained within a single `*.cs` file that are built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). ## Options diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index 5f9384b7dd26e..07af74e43ffa4 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -83,7 +83,19 @@ To run the application, the `dotnet run` command resolves the dependencies of th - **`--file `** - The path to the file-based program 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# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). + 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). + + 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: + + ```csharp + #!/usr/bin/env dotnet run + ``` + + Then you can run the file directly from the command line: + + ```bash + ./ConsoleApp.cs + ``` Introduced in .NET SDK 10.0.100. @@ -167,13 +179,13 @@ The environment is constructed in the same order as this list, so the `-e|--envi dotnet run ``` -- Run the specified file-based program with arguments: +- Run the specified file-based app with arguments: ```dotnetcli dotnet run ConsoleApp.cs -- arg1 arg2 ``` - File-based program support was added in .NET SDK 10.0.100. + File-based app support was added in .NET SDK 10.0.100. - Run the specified project: From 31278b0d509cd04aa5e3f29c5b9ccd4fa3227d9a Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Thu, 25 Sep 2025 12:16:36 -0700 Subject: [PATCH 11/14] move project-solution-file arguments to an include file --- docs/core/tools/dotnet-build.md | 10 +--------- docs/core/tools/dotnet-clean.md | 10 +--------- docs/core/tools/dotnet-publish.md | 10 +--------- docs/core/tools/dotnet-restore.md | 10 +--------- includes/cli-arguments-project-solution-file.md | 14 ++++++++++++++ 5 files changed, 18 insertions(+), 36 deletions(-) create mode 100644 includes/cli-arguments-project-solution-file.md diff --git a/docs/core/tools/dotnet-build.md b/docs/core/tools/dotnet-build.md index a3dae67450788..d4ac620eb2725 100644 --- a/docs/core/tools/dotnet-build.md +++ b/docs/core/tools/dotnet-build.md @@ -75,15 +75,7 @@ Running `dotnet build` is equivalent to running `dotnet msbuild -restore`; howev ## Arguments -`PROJECT | SOLUTION | FILE` - -The project or solution or C# (file-based app) file to build. If a file isn't specified, MSBuild searches the current directory for a project or solution. - -- `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. - -- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. - -- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# programs](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +[!INCLUDE [arguments-project-solution-file](../../../includes/cli-arguments-project-solution-file.md)] ## Options diff --git a/docs/core/tools/dotnet-clean.md b/docs/core/tools/dotnet-clean.md index e2ed7dddcf2fa..b2c8104351c73 100644 --- a/docs/core/tools/dotnet-clean.md +++ b/docs/core/tools/dotnet-clean.md @@ -30,15 +30,7 @@ The `dotnet clean` command cleans the output of the previous build. It's impleme ## Arguments -`PROJECT | SOLUTION | FILE` - -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. - -- `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. - -- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. - -- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +[!INCLUDE [arguments-project-solution-file](../../../includes/cli-arguments-project-solution-file.md)] ## Options diff --git a/docs/core/tools/dotnet-publish.md b/docs/core/tools/dotnet-publish.md index 073a1a054d05f..c15c7205b6b47 100644 --- a/docs/core/tools/dotnet-publish.md +++ b/docs/core/tools/dotnet-publish.md @@ -114,15 +114,7 @@ For more information, see the following resources: ## Arguments -`PROJECT | SOLUTION | FILE` - -The project or solution or C# (file-based program) file to publish. If a file isn't specified, MSBuild searches the current directory for a project or solution. - -- `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. - -- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. - -- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +[!INCLUDE [arguments-project-solution-file](../../../includes/cli-arguments-project-solution-file.md)] ## Options diff --git a/docs/core/tools/dotnet-restore.md b/docs/core/tools/dotnet-restore.md index 600a6931eff59..2ca8374b29b70 100644 --- a/docs/core/tools/dotnet-restore.md +++ b/docs/core/tools/dotnet-restore.md @@ -86,15 +86,7 @@ There are three specific settings that `dotnet restore` ignores: ## Arguments -`PROJECT | SOLUTION | FILE` - -The project or solution or C# (file-based app) file to restore. If a file isn't specified, MSBuild searches the current directory for a project or solution. - -- `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. If the directory is not specified, it defaults to the current directory. - -- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. If the directory is not specified, it defaults to the current directory. - -- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (`*.csproj`) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). +[!INCLUDE [arguments-project-solution-file](../../../includes/cli-arguments-project-solution-file.md)] ## Options diff --git a/includes/cli-arguments-project-solution-file.md b/includes/cli-arguments-project-solution-file.md new file mode 100644 index 0000000000000..d7a4dd6817202 --- /dev/null +++ b/includes/cli-arguments-project-solution-file.md @@ -0,0 +1,14 @@ +--- +ms.date: 09/25/2025 +ms.topic: include +--- + +`PROJECT | SOLUTION | FILE` + +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. + +- `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. + +- `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. + +- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (*.csproj*) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). \ No newline at end of file From bfacaa6682ef97f9826cc69084e861167ae9fae8 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Thu, 25 Sep 2025 12:20:27 -0700 Subject: [PATCH 12/14] add trailing newline to include --- includes/cli-arguments-project-solution-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/cli-arguments-project-solution-file.md b/includes/cli-arguments-project-solution-file.md index d7a4dd6817202..afa1280f4aabe 100644 --- a/includes/cli-arguments-project-solution-file.md +++ b/includes/cli-arguments-project-solution-file.md @@ -11,4 +11,4 @@ The project or solution or C# (file-based app) file to clean. If a file isn't sp - `SOLUTION` is the path and filename of a solution file (*.sln* or *.slnx* extension), or the path to a directory that contains a solution file. -- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (*.csproj*) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). \ No newline at end of file +- `FILE` is an argument added in .NET 10. The path and filename of a file-based app. File-based apps are contained within a single file that is built and run without a corresponding project (*.csproj*) file. For more information, see [Build file-based C# apps](/dotnet/csharp/fundamentals/tutorials/file-based-programs). From 5cbb5137bf214e3ea856f077cedc91a9ff533f77 Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Thu, 25 Sep 2025 12:53:15 -0700 Subject: [PATCH 13/14] specify behavior of dotnet run for arguments and using file option --- docs/core/tools/dotnet-run.md | 20 ++++++++++++++++--- .../cli-arguments-project-solution-file.md | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index 07af74e43ffa4..8ca96622f9b44 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -58,6 +58,8 @@ To run the application, the `dotnet run` command resolves the dependencies of th `` Arguments passed to the application that is being run. + + 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. ## Options @@ -83,7 +85,7 @@ To run the application, the `dotnet run` command resolves the dependencies of th - **`--file `** - 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). + 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). 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: @@ -179,10 +181,10 @@ The environment is constructed in the same order as this list, so the `-e|--envi dotnet run ``` -- Run the specified file-based app with arguments: +- Run the specified file-based app in the current directory: ```dotnetcli - dotnet run ConsoleApp.cs -- arg1 arg2 + dotnet run --file ConsoleApp.cs ``` 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 ```dotnetcli dotnet run --verbosity m ``` + +- Run the project in the current directory using the specified framework and pass arguments to the application: + + ```dotnetcli + dotnet run -f net6.0 -- arg1 arg2 + ``` + + In the following example, three arguments are passed to the application. One argument is passed using `-`, and two arguments are passed after `--`: + + ```dotnetcli + dotnet run -f net6.0 -arg1 -- arg2 arg3 + ``` \ No newline at end of file diff --git a/includes/cli-arguments-project-solution-file.md b/includes/cli-arguments-project-solution-file.md index afa1280f4aabe..74d417e64a9ea 100644 --- a/includes/cli-arguments-project-solution-file.md +++ b/includes/cli-arguments-project-solution-file.md @@ -5,7 +5,7 @@ ms.topic: include `PROJECT | SOLUTION | FILE` -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. +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. - `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. From 3a465f4b1832f3ffca3f2dbb3997cbe99bfbf45d Mon Sep 17 00:00:00 2001 From: "Meaghan Osagie (Lewis)" Date: Thu, 25 Sep 2025 13:28:34 -0700 Subject: [PATCH 14/14] Add trailing newline at end of file --- docs/core/tools/dotnet-run.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/core/tools/dotnet-run.md b/docs/core/tools/dotnet-run.md index 8ca96622f9b44..52d837939bb34 100644 --- a/docs/core/tools/dotnet-run.md +++ b/docs/core/tools/dotnet-run.md @@ -223,4 +223,5 @@ The environment is constructed in the same order as this list, so the `-e|--envi ```dotnetcli dotnet run -f net6.0 -arg1 -- arg2 arg3 - ``` \ No newline at end of file + ``` + \ No newline at end of file