dotnet-installer/Documentation/manpages/sdk/dotnet-build.1
2018-05-30 15:52:55 +00:00

195 lines
7.3 KiB
Groff

.\" Automatically generated by Pandoc 2.2.1
.\"
.TH "dotnet build command \- .NET Core CLI" "1" "" "" ".NET Core"
.hy
.SH dotnet\-build
.PP
.SH NAME
.PP
\f[C]dotnet\ build\f[] \- Builds a project and all of its dependencies.
.SH SYNOPSIS
.SS .NET Core 2.x
.IP
.nf
\f[C]
dotnet\ build\ [<PROJECT>]\ [\-c|\-\-configuration]\ [\-f|\-\-framework]\ [\-\-force]\ [\-\-no\-dependencies]\ [\-\-no\-incremental]
\ \ \ \ [\-\-no\-restore]\ [\-o|\-\-output]\ [\-r|\-\-runtime]\ [\-v|\-\-verbosity]\ [\-\-version\-suffix]
dotnet\ build\ [\-h|\-\-help]
\f[]
.fi
.SS .NET Core 1.x
.IP
.nf
\f[C]
dotnet\ build\ [<PROJECT>]\ [\-c|\-\-configuration]\ [\-f|\-\-framework]\ [\-\-no\-dependencies]\ [\-\-no\-incremental]\ [\-o|\-\-output]
\ \ \ \ [\-r|\-\-runtime]\ [\-v|\-\-verbosity]\ [\-\-version\-suffix]
dotnet\ build\ [\-h|\-\-help]
\f[]
.fi
.PP
* * * * *
.SH DESCRIPTION
.PP
The \f[C]dotnet\ build\f[] 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 \f[I].dll\f[] extension and symbol files used for debugging with a \f[I].pdb\f[] extension.
A dependencies JSON file (\f[I]*.deps.json\f[]) is produced that lists the dependencies of the application.
A \f[I]*.runtimeconfig.json\f[] file is produced, which specifies the shared runtime and its version for the application.
.PP
If the project has third\-party dependencies, such as libraries from NuGet, they're resolved from the NuGet cache and aren't available with the project's built output.
With that in mind, the product of \f[C]dotnet\ build\f[] isn't ready to be transferred to another machine to run.
This is in contrast to the behavior of the .NET Framework in which building an executable project (an application) produces output that's runnable on any machine where the .NET Framework is installed.
To have a similar experience with .NET Core, you need to use the dotnet publish command.
For more information, see .NET Core Application Deployment.
.PP
Building requires the \f[I]project.assets.json\f[] file, which lists the dependencies of your application.
The file is created when \f[C]dotnet\ restore\f[] is executed.
Without the assets file in place, the tooling cannot resolve reference assemblies, which results in errors.
With .NET Core 1.x SDK, you needed to explicitly run the \f[C]dotnet\ restore\f[] before running \f[C]dotnet\ build\f[].
Starting with .NET Core 2.0 SDK, \f[C]dotnet\ restore\f[] runs implicitly when you run \f[C]dotnet\ build\f[].
If you want to disable implicit restore when running the build command, you can pass the \f[C]\-\-no\-restore\f[] option.
.PP
.PP
\f[C]dotnet\ build\f[] uses MSBuild to build the project, so it supports both parallel and incremental builds.
For more information, see Incremental Builds.
.PP
In addition to its options, the \f[C]dotnet\ build\f[] command accepts MSBuild options, such as \f[C]/p\f[] for setting properties or \f[C]/l\f[] to define a logger.
For more information about these options, see the MSBuild Command\-Line Reference.
.PP
Whether the project is executable or not is determined by the \f[C]<OutputType>\f[] property in the project file.
The following example shows a project that produces executable code:
.IP
.nf
\f[C]
<PropertyGroup>
\ \ <OutputType>Exe</OutputType>
</PropertyGroup>
\f[]
.fi
.PP
In order to produce a library, omit the \f[C]<OutputType>\f[] property.
The main difference in built output is that the IL DLL for a library doesn't contain entry points and can't be executed.
.SS Arguments
.PP
\f[C]PROJECT\f[]
.PP
The project file to build.
If a project file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in \f[I]proj\f[] and uses that file.
.SH OPTIONS
.SS .NET Core 2.x
.PP
\f[C]\-c|\-\-configuration\ {Debug|Release}\f[]
.PP
Defines the build configuration.
The default value is \f[C]Debug\f[].
.PP
\f[C]\-f|\-\-framework\ <FRAMEWORK>\f[]
.PP
Compiles for a specific framework.
The framework must be defined in the project file.
.PP
\f[C]\-\-force\f[]
.PP
Forces all dependencies to be resolved even if the last restore was successful.
Specifying this flag is the same as deleting the \f[I]project.assets.json\f[] file.
.PP
\f[C]\-h|\-\-help\f[]
.PP
Prints out a short help for the command.
.PP
\f[C]\-\-no\-dependencies\f[]
.PP
Ignores project\-to\-project (P2P) references and only builds the specified root project.
.PP
\f[C]\-\-no\-incremental\f[]
.PP
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.
.PP
\f[C]\-\-no\-restore\f[]
.PP
Doesn't execute an implicit restore during build.
.PP
\f[C]\-o|\-\-output\ <OUTPUT_DIRECTORY>\f[]
.PP
Directory in which to place the built binaries.
You also need to define \f[C]\-\-framework\f[] when you specify this option.
.PP
\f[C]\-r|\-\-runtime\ <RUNTIME_IDENTIFIER>\f[]
.PP
Specifies the target runtime.
For a list of Runtime Identifiers (RIDs), see the RID catalog.
.PP
\f[C]\-v|\-\-verbosity\ <LEVEL>\f[]
.PP
Sets the verbosity level of the command.
Allowed values are \f[C]q[uiet]\f[], \f[C]m[inimal]\f[], \f[C]n[ormal]\f[], \f[C]d[etailed]\f[], and \f[C]diag[nostic]\f[].
.PP
\f[C]\-\-version\-suffix\ <VERSION_SUFFIX>\f[]
.PP
Defines the version suffix for an asterisk (\f[C]*\f[]) in the version field of the project file.
The format follows NuGet's version guidelines.
.SS .NET Core 1.x
.PP
\f[C]\-c|\-\-configuration\ {Debug|Release}\f[]
.PP
Defines the build configuration.
The default value is \f[C]Debug\f[].
.PP
\f[C]\-f|\-\-framework\ <FRAMEWORK>\f[]
.PP
Compiles for a specific framework.
The framework must be defined in the project file.
.PP
\f[C]\-h|\-\-help\f[]
.PP
Prints out a short help for the command.
.PP
\f[C]\-\-no\-dependencies\f[]
.PP
Ignores project\-to\-project (P2P) references and only builds the specified root project.
.PP
\f[C]\-\-no\-incremental\f[]
.PP
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.
.PP
\f[C]\-o|\-\-output\ <OUTPUT_DIRECTORY>\f[]
.PP
Directory in which to place the built binaries.
You also need to define \f[C]\-\-framework\f[] when you specify this option.
.PP
\f[C]\-r|\-\-runtime\ <RUNTIME_IDENTIFIER>\f[]
.PP
Specifies the target runtime.
For a list of Runtime Identifiers (RIDs), see the RID catalog.
.PP
\f[C]\-v|\-\-verbosity\ <LEVEL>\f[]
.PP
Sets the verbosity level of the command.
Allowed values are \f[C]q[uiet]\f[], \f[C]m[inimal]\f[], \f[C]n[ormal]\f[], \f[C]d[etailed]\f[], and \f[C]diag[nostic]\f[].
.PP
\f[C]\-\-version\-suffix\ <VERSION_SUFFIX>\f[]
.PP
Defines the version suffix for an asterisk (\f[C]*\f[]) in the version field of the project file.
The format follows NuGet's version guidelines.
.PP
* * * * *
.SH EXAMPLES
.PP
Build a project and its dependencies:
.PP
\f[C]dotnet\ build\f[]
.PP
Build a project and its dependencies using Release configuration:
.PP
\f[C]dotnet\ build\ \-\-configuration\ Release\f[]
.PP
Build a project and its dependencies for a specific runtime (in this example, Ubuntu 16.04):
.PP
\f[C]dotnet\ build\ \-\-runtime\ ubuntu.16.04\-x64\f[]
.PP
Build the project and use the specified NuGet package source during the restore operation (.NET Core SDK 2.0 and later versions):
.PP
\f[C]dotnet\ build\ \-\-source\ c:\\packages\\mypackages\f[]
.SH AUTHORS
mairaw.