liveBook · Manning

Dotnet build

As explained in ASP.NET Core in Action, 3e

dotnet build is a .NET CLI command that compiles a .NET project and produces runnable build outputs when compilation succeeds.

dotnet build compiles a .NET project from its project folder. When compilation succeeds, it creates build artifacts in the bin folder, including the application’s .dll file. section 3.2.2 section 27.1.1

Use dotnet build as part of the normal .NET CLI workflow:

  • Run it inside the project folder to compile that project. section 3.2.2
  • Expect package restoration to happen implicitly unless automatic restoration is disabled. section 3.2.2
  • Use dotnet run afterward to execute the built application; use dotnet publish when deployment packaging is required. section 27.1.1

Compile a project

From the project directory, run dotnet build. A successful build places the compiled application, such as ExampleApp.dll, under bin. On Windows, an accompanying .exe wrapper may also appear. section 3.2.2 section 27.1.1

The dotnet build command runs dotnet restore implicitly. Similarly, dotnet run runs dotnet build and dotnet restore. If you don’t want to run the previous steps automatically, you can use the --no-restore and --no-build flags, as in dotnet build --no-restore.
CH03_F05_UN01_Lock3

Compare the implicit restore and build steps with --no-restore and --no-build options. section 3.2.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains command location, implicit restoration, and bin outputs but does not detail compilation internals.
Examples
Uses a project-folder command and an ExampleApp.dll output in the bin directory.
What it assumes
Assumes a prepared .NET project and explains package restoration rather than requiring manual restore first.
What you can do after
Operate/configure it from a project folder to compile an application and inspect its bin artifacts.
How it connects
Connects dotnet build with .NET CLI, NuGet, dotnet restore, dotnet run, dotnet publish, and Visual Studio.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.