1dotnet build command(1)            .NET Core           dotnet build command(1)
2
3
4

dotnet build

6       This article applies to: ✓ .NET Core 1.x SDK and later versions
7

NAME

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

SYNOPSIS

12              dotnet build [<PROJECT>|<SOLUTION>] [-c|--configuration] [-f|--framework] [--force] [--interactive] [--no-dependencies]
13                  [--no-incremental] [--nologo] [--no-restore] [-o|--output] [-r|--runtime] [-v|--verbosity] [--version-suffix]
14
15              dotnet build [-h|--help]
16

DESCRIPTION

18       The dotnet build command builds the project and its dependencies into a
19       set of binaries.  The binaries include the project’s code in Intermedi‐
20       ate Language (IL) files with a .dll extension and symbol files used for
21       debugging  with  a  .pdb   extension.    A   dependencies   JSON   file
22       (*.deps.json)  is  produced that lists the dependencies of the applica‐
23       tion.  A *.runtimeconfig.json file is  produced,  which  specifies  the
24       shared runtime and its version for the application.
25
26       If  the  project  has  third-party dependencies, such as libraries from
27       NuGet, they’re resolved from the NuGet cache and aren’t available  with
28       the  project’s  built output.  With that in mind, the product of dotnet
29       build isn’t ready to be transferred to another machine to run.  This is
30       in  contrast to the behavior of the .NET Framework in which building an
31       executable project (an application) produces output that’s runnable  on
32       any  machine  where the .NET Framework is installed.  To have a similar
33       experience with .NET Core, you need to use the dotnet publish  command.
34       For more information, see .NET Core Application Deployment.
35
36       Building  requires the project.assets.json file, which lists the depen‐
37       dencies of your application.  The file is created when  dotnet  restore
38       is  executed.   Without the assets file in place, the tooling can’t re‐
39       solve reference assemblies, which results in errors.   With  .NET  Core
40       1.x SDK, you needed to explicitly run the dotnet restore before running
41       dotnet build.  Starting with .NET Core 2.0 SDK, dotnet restore runs im‐
42       plicitly  when  you  run dotnet build.  If you want to disable implicit
43       restore when running the build command, you can pass  the  --no-restore
44       option.
45
46       Whether  the project is executable or not is determined by the <Output‐
47       Type> property in the project file.   The  following  example  shows  a
48       project that produces executable code:
49
50              <PropertyGroup>
51                <OutputType>Exe</OutputType>
52              </PropertyGroup>
53
54       To produce a library, omit the <OutputType> property.  The main differ‐
55       ence in built output is that the IL DLL for a library  doesn’t  contain
56       entry points and can’t be executed.
57
58   MSBuild
59       dotnet  build  uses  MSBuild  to build the project, so it supports both
60       parallel and incremental builds.  For more information, see Incremental
61       Builds.
62
63       In  addition  to  its options, the dotnet build command accepts MSBuild
64       options, such as -p for setting properties or -l to  define  a  logger.
65       For  more information about these options, see the MSBuild Command-Line
66       Reference.  Or you can also use the dotnet msbuild command.
67
68       Running dotnet build is equivalent to  dotnet  msbuild  -restore  -tar‐
69       get:Build.
70
71   Arguments
72       PROJECT | SOLUTION
73
74       The  project  or solution file to build.  If a project or solution file
75       isn’t specified, MSBuild searches the current working directory  for  a
76       file that has a file extension that ends in either proj or sln and uses
77       that file.
78

OPTIONS

80       · -c|--configuration {Debug|Release}
81
82         Defines the build configuration.  The default value is Debug.
83
84       · -f|--framework <FRAMEWORK>
85
86         Compiles for a specific framework.  The framework must be defined  in
87         the project file.
88
89       · --force
90
91         Forces  all  dependencies to be resolved even if the last restore was
92         successful.  Specifying  this  flag  is  the  same  as  deleting  the
93         project.assets.json file.  Available since .NET Core 2.0 SDK.
94
95       · -h|--help
96
97         Prints out a short help for the command.
98
99       · --interactive
100
101         Allows  the  command  to stop and wait for user input or action.  For
102         example, to complete authentication.  Available since .NET  Core  3.0
103         SDK.
104
105       · --no-dependencies
106
107         Ignores project-to-project (P2P) references and only builds the spec‐
108         ified root project.
109
110       · --no-incremental
111
112         Marks the build as unsafe for incremental build.  This flag turns off
113         incremental  compilation  and forces a clean rebuild of the project’s
114         dependency graph.
115
116       · --no-logo
117
118         Doesn’t display the startup banner or the copyright message.   Avail‐
119         able since .NET Core 3.0 SDK.
120
121       · --no-restore
122
123         Doesn’t  execute  an  implicit restore during build.  Available since
124         .NET Core 2.0 SDK.
125
126       · -o|--output <OUTPUT_DIRECTORY>
127
128         Directory in which to place the built binaries.  You also need to de‐
129         fine --framework when you specify this option.  If not specified, the
130         default path is ./bin/<configuration>/<framework>/.
131
132       · -r|--runtime <RUNTIME_IDENTIFIER>
133
134         Specifies the target runtime.  For  a  list  of  Runtime  Identifiers
135         (RIDs), see the RID catalog.
136
137       · -v|--verbosity <LEVEL>
138
139         Sets the MSBuild verbosity level.  Allowed values are q[uiet], m[ini‐
140         mal], n[ormal], d[etailed], and diag[nostic].  The default  is  mini‐
141         mal.
142
143       · --version-suffix <VERSION_SUFFIX>
144
145         Sets  the value of the $(VersionSuffix) property to use when building
146         the project.  This only works if the $(Version) property  isn’t  set.
147         Then,  $(Version)  is  set  to the $(VersionPrefix) combined with the
148         $(VersionSuffix), separated by a dash.
149

EXAMPLES

151       · Build a project and its dependencies:
152
153                dotnet build
154
155       · Build a project and its dependencies using Release configuration:
156
157                dotnet build --configuration Release
158
159       · Build a project and its dependencies for a specific runtime (in  this
160         example, Ubuntu 18.04):
161
162                dotnet build --runtime ubuntu.18.04-x64
163
164       · Build  the  project and use the specified NuGet package source during
165         the restore operation (.NET Core 2.0 SDK and later versions):
166
167                dotnet build --source c:\packages\mypackages
168
169       · Build the project and set 1.2.3.4 version as a build parameter:
170
171                dotnet build -p:Version=1.2.3.4
172
173
174
175                                                       dotnet build command(1)
Impressum