dotnet build command - .NET CLI (2023)

  • Article
  • 6 minutes to read

This article applies to: ✔️ .NET Core 3.1 SDK and later versions


dotnet build - Builds a project and all of its dependencies.


dotnet build [<PROJECT>|<SOLUTION>] [-a|--arch <ARCHITECTURE>] [-c|--configuration <CONFIGURATION>] [-f|--framework <FRAMEWORK>] [--force] [--interactive] [--no-dependencies] [--no-incremental] [--no-restore] [--nologo] [--no-self-contained] [--os <OS>] [-o|--output <OUTPUT_DIRECTORY>] [-r|--runtime <RUNTIME_IDENTIFIER>] [--self-contained [true|false]] [--source <SOURCE>] [--use-current-runtime, --ucr [true|false]] [-v|--verbosity <LEVEL>] [--version-suffix <VERSION_SUFFIX>]dotnet build -h|--help


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:

  • An executable that can be used to run the application, if the project type is an executable targeting .NET Core 3.0 or later.
  • 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 command). For more information, see .NET Application Deployment.

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

Building requires the project.assets.json file, which lists the dependencies of your application. The file is created when dotnet restore is executed. Without the assets file in place, the tooling can't resolve reference assemblies, which results in errors.

You don't have to run dotnet restore because it's run implicitly by all commands that require a restore to occur, such as dotnet new, dotnet build, dotnet run, dotnet test, dotnet publish, and dotnet pack. To disable implicit restore, use the --no-restore option.

The dotnet restore command is still useful in certain scenarios where explicitly restoring makes sense, such as continuous integration builds in Azure DevOps Services or in build systems that need to explicitly control when the restore occurs.

For information about how to manage NuGet feeds, see the dotnet restore documentation.

This command supports the dotnet restore options when passed in the long form (for example, --source). Short form options, such as -s, are not supported.

Executable or library output

Whether the project is executable or not is determined by the <OutputType> property in the project file. The following example shows a project that produces executable code:

(Video) Intro To The .NET CLI - How To Use It, Why We Need It, And More

<PropertyGroup> <OutputType>Exe</OutputType></PropertyGroup>

To produce a library, omit the <OutputType> property or change its value to Library. The IL DLL for a library doesn't contain entry points and can't be executed.


dotnet build uses MSBuild to build the project, so it supports both parallel and incremental builds. For more information, see 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. Or you can also use the dotnet msbuild command.


When dotnet build is run automatically by dotnet run, arguments like -property:property=value aren't respected.

Running dotnet build is equivalent to running dotnet msbuild -restore; however, the default verbosity of the output is different.

Workload manifest downloads

When you run this command, it initiates an asynchronous background download of advertising manifests for workloads. If the download is still running when this command finishes, the download is stopped. For more information, see Advertising manifests.



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.


  • -a|--arch <ARCHITECTURE>

    Specifies the target architecture. This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --arch x86 sets the RID to win-x86. If you use this option, don't use the -r|--runtime option. Available since .NET 6 Preview 7.

  • -c|--configuration <CONFIGURATION>

    (Video) Learn Command Line Interface (CLI) for Build, Run and Publish in .NET Core | Infologs

    Defines the build configuration. The default for most projects is Debug, but you can override the build configuration settings in your project.

  • -f|--framework <FRAMEWORK>

    Compiles for a specific framework. The framework must be defined in the project file. Examples: net7.0, net462.

  • --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.

  • -?|-h|--help

    Prints out a description of how to use the command.

  • --interactive

    Allows the command to stop and wait for user input or action. For example, to complete authentication. Available since .NET Core 3.0 SDK.

  • --no-dependencies

    Ignores project-to-project (P2P) references and only builds the specified root project.

  • --no-incremental

    Marks the build as unsafe for incremental build. This flag turns off incremental compilation and forces a clean rebuild of the project's dependency graph.

    (Video) How to create your own .NET CLI tools to make your life easier

  • --no-restore

    Doesn't execute an implicit restore during build.

  • --nologo

    Doesn't display the startup banner or the copyright message.

  • --no-self-contained

    Publishes the application as a framework dependent application. A compatible .NET runtime must be installed on the target machine to run the application. Available since .NET 6 SDK.

  • -o|--output <OUTPUT_DIRECTORY>

    Directory in which to place the built binaries. If not specified, the default path is ./bin/<configuration>/<framework>/. For projects with multiple target frameworks (via the TargetFrameworks property), you also need to define --framework when you specify this option.

  • --os <OS>

    Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don't use the -r|--runtime option. Available since .NET 6.

  • -r|--runtime <RUNTIME_IDENTIFIER>

    Specifies the target runtime. For a list of Runtime Identifiers (RIDs), see the RID catalog. If you use this option with .NET 6 SDK, use --self-contained or --no-self-contained also. If not specified, the default is to build for the current OS and architecture.

  • --self-contained [true|false]

    (Video) Create new Solution & Projects using Dotnet CLI

    Publishes the .NET runtime with the application so the runtime doesn't need to be installed on the target machine. The default is true if a runtime identifier is specified. Available since .NET 6 SDK.

  • --source <SOURCE>

    The URI of the NuGet package source to use during the restore operation.

-v|--verbosity <LEVEL>

Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]. The default is minimal. By default, MSBuild displays warnings and errors at all verbosity levels. To exclude warnings, use /property:WarningLevel=0. For more information, see LoggerVerbosity and WarningLevel.

  • --use-current-runtime, --ucr [true|false]

    Sets the RuntimeIdentifier to a platform portable RuntimeIdentifier based on the one of your machine. This happens implicitly with properties that require a RuntimeIdentifier, such as SelfContained, PublishAot, PublishSelfContained, PublishSingleFile, and PublishReadyToRun. If the property is set to false, that implicit resolution will no longer occur.

  • --version-suffix <VERSION_SUFFIX>

    Sets the value of the $(VersionSuffix) property to use when building the project. This only works if the $(Version) property isn't set. Then, $(Version) is set to the $(VersionPrefix) combined with the $(VersionSuffix), separated by a dash.


  • Build a project and its dependencies:

    dotnet build
  • Build a project and its dependencies using Release configuration:

    dotnet build --configuration Release
  • Build a project and its dependencies for a specific runtime (in this example, Ubuntu 18.04):

    dotnet build --runtime ubuntu.18.04-x64
  • Build the project and use the specified NuGet package source during the restore operation:

    (Video) Dotnet CLI - Build, Test and Publish projects

    dotnet build --source c:\packages\mypackages
  • Build the project and set version as a build parameter using the -p MSBuild option:

    dotnet build -p:Version=


What is .NET CLI command? ›

The . NET command-line interface (CLI) is a cross-platform toolchain for developing, building, running, and publishing . NET applications.

What is .NET build? ›

NET is an open-source platform for building desktop, web, and mobile applications that can run natively on any operating system. The . NET system includes tools, libraries, and languages that support modern, scalable, and high-performance software development. An active developer community maintains and supports the .

How do I open a .net command prompt? ›

On the menu bar, select Tools > Command Line > Developer Command Prompt or Developer PowerShell.

How do I access .net CLI in Visual Studio? ›

You can run the generated C# code projects with Visual Studio by pressing the F5 key or with dotnet run (. NET CLI).

How do I run a .NET Core console application from command prompt? ›

In . NET Core, it runs from the dll, so you have to just run the application by running the command prompt and using the command - dotnet run. Open your command prompt and go to that folder where your application persists. This resulted in printing "Hello World!" as it is written in our console application.

How to run C# console application from command prompt? ›

Steps to Execute C# Program on cmd

Step 1: Open the text editor like Notepad or Notepad++, and write the code that you want to execute. Now save the file with . cs extension. If your program has no error then it will create a filename.exe file in the same directory where you have saved your program.

What is build in C#? ›

Builder is a creational design pattern, which allows constructing complex objects step by step. Unlike other creational patterns, Builder doesn't require products to have a common interface.

Does dotnet run also build? ›

Builds and runs the app using the specified framework. The framework must be specified in the project file. Forces all dependencies to be resolved even if the last restore was successful.

Is CLI same as CMD? ›

Command Line Interface (CLI): Basic functionality is to take inputs from Keyboard and send it to an application or system and then display text-based output returned by the application - CLI requires Shell to run. Command Prompt: Same as Shell but developed by Microsoft(mostly used in Windows systems).

What are the three 3 CLI modes? ›

- [Instructor] The Cisco Inner Operating System, the IOS has three command line modes, User EXEC mode, or user mode, Privileged EXEC mode, or privileged mode, and then the Global Configuration mode.

What is CLI example? ›

The MS-DOS operating system and the command shell in the Windows operating system are examples of command-line interfaces. In addition, programming language development platforms such as Python can support command-line interfaces.

How do I check my CLI? ›

To Check Angular CLI version use ng --version or ng v or npm list -global --depth 0 commands. ng --version command returns the details of version of Angular CLI installed and in addition to that version of Angular development packages like @angular-devkit/architect,rxjs etc.. as shown below.

How do I Run a CLI command in Visual Studio code? ›

To get an overview of the VS Code command-line interface, open a terminal or command prompt and type code --help . You will see the version, usage example, and list of command line options.

How do I get all commands in CMD? ›

Type help and press ↵ Enter . A list of all the available commands will be displayed. The listed is sorted alphabetically. The list is usually larger than the Command Prompt window, so you may need to scroll up to find the command you want.

How many CLI commands are there? ›

The Command Prompt in Windows provides access to over 280 commands. These commands are used to do certain operating system tasks from a command-line interpreter instead of the graphical Windows interface we use most of the time.

Can I boot using command prompt? ›

If you're troubleshooting your computer, you may need to boot Windows 10 in the Command Prompt. If Windows 10 can't boot at all, the command line interface (CLI) is the only option you have. Booting Windows 10 in Command Prompt requires that you have Windows 10 on a bootable disc or USB drive.

How does dotnet build work? ›

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.

How to compile C# from command line? ›

You can invoke the C# compiler by typing the name of its executable file (csc.exe) at a command prompt. For . NET Framework projects, you can also run csc.exe from the command line. Every compiler option is available in two forms: -option and /option.

Which .NET CLI command creates a new console application? ›

The dotnet new command creates a . NET project or other artifacts based on a template. The command calls the template engine to create the artifacts on disk based on the specified template and options.

What is build vs compile? ›

Build is a compiled version of a program. Compile means, convert (a program) into a machine-code or lower-level form in which the program can be executed.

What is build in code? ›

In a programming context, a build is a version of a program that, as a rule, is a pre-release version and is identified by a build number rather than by a release number. Simply put, a software build is a set of executable code that is ready for use by customers.

What is build example? ›

Example Sentences

Verb The bridge was built in the 1890s. The planes were built in Germany. The organization helps build houses for poor families.

What is Mvn build command? ›

To build a Maven project via the command line, you use the mvn command from the command line. The command must be executed in the directory which contains the relevant pom file. You pass the build life cycle, phase or goal as parameter to this command.

What .NET framework is installed cmd? ›

You can also press the Windows key + R shortcut, then enter "cmd" in the Run dialog box. Then, press CTRL + SHIFT + ENTER to open the Command Prompt. Run The Initial Check . Net Version Command: Type in reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s to run the initial check.

Does dotnet test do a build? ›

The dotnet test command is used to execute unit tests in a given solution. The dotnet test command builds the solution and runs a test host application for each test project in the solution.

Is .NET built on C#? ›

. NET Framework applications are written in C#, F#, or Visual Basic and compiled to Common Intermediate Language (CIL). The Common Language Runtime (CLR) runs .

What is difference between dotnet build and publish? ›

Build compiles the source code into a (hopefully) runnable application. Publish takes the results of the build, along with any needed third-party libraries and puts it somewhere for other people to run it.

What is the use of CLI command? ›

CLI is a command line program that accepts text input to execute operating system functions. In the 1960s, using only computer terminals, this was the only way to interact with computers. In the 1970s an 1980s, command line input was commonly used by Unix systems and PC systems like MS-DOS and Apple DOS.

How do I open .net CLI in Visual Studio 2022? ›

You can run the generated C# code projects with Visual Studio by pressing the F5 key or with dotnet run (. NET CLI).

What does CLI mean in Cisco? ›

This section provides information about the basic Cisco IOS commands that you need to configure your router. If you are familiar with the Cisco IOS command line interface (CLI), skip this section. Summary of Main Cisco IOS Command Modes.

Is CLI a Terminal? ›

Background: The command line interface is a program on your computer that allows you to create and delete files, run programs, and navigate through folders and files. On a Mac, it's called Terminal, and on Windows, it's Command Prompt.

What are three different types of CLI? ›

Application command-line interfaces

Applications can also have command line interfaces. Applications might support either or all of these three main types of command line interface mechanisms: parameters, interactive command line sessions, OS inter-process communication.

Can you use CLI on Windows? ›

The Azure Command-Line Interface (CLI) is a cross-platform command-line tool that can be installed locally on Windows computers. You can use the Azure CLI for Windows to connect to Azure and execute administrative commands on Azure resources.

What language is used in CLI? ›

The CLI includes the Common Type System (CTS) and Common Language Specification (CLS). No matter which programming language they are written in, CLI applications are compiled into Intermediate Language (IL), which is further compiled into the target machine language by the Common Language Runtime (CLR) software.

How do I run a CLI command in Visual Studio Code? ›

To get an overview of the VS Code command-line interface, open a terminal or command prompt and type code --help . You will see the version, usage example, and list of command line options.

What is CLI boot? ›

Spring Boot CLI is a command-line abstraction that allows us to easily run Spring micro-services expressed as Groovy scripts. It also provides simplified and enhanced dependency management for those services.

How do I access the CLI on my Cisco router? ›

To access your router's command line interface, use the screen command. The syntax is: screen [device name]. In the example below, the command screen /dev/tty.

What are CLI settings? ›

CLI stands for command line interface, a configuration mode that gives users direct access to all the settings and parameters within the flight control firmware.


1. Install and Use a NuGet Package with the .NET CLI | NuGet 101 [3 of 5]
2. Using System.CommandLine to Build CLI Apps
(Muhammad Rehan Saeed)
3. Create a console application using .NET command line / CLI
(Learn Now!)
4. Core Tutorial -- Dotnet CLI commands
(JyoPat Tech Guru)
5. .NET Core Command Line Interface (CLI) | Learn the Basics
6. Create .NET Core Projects with the Command Line
(Microsoft Visual Studio)
Top Articles
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated: 01/11/2023

Views: 6182

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.