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

dotnet pack

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

NAME

9       dotnet pack - Packs the code into a NuGet package.
10

SYNOPSIS

12              dotnet pack [<PROJECT>|<SOLUTION>] [-c|--configuration] [--force] [--include-source] [--include-symbols] [--interactive]
13                  [--no-build] [--no-dependencies] [--no-restore] [--nologo] [-o|--output] [--runtime] [-s|--serviceable]
14                  [-v|--verbosity] [--version-suffix]
15              dotnet pack [-h|--help]
16

DESCRIPTION

18       The  dotnet pack command builds the project and creates NuGet packages.
19       The result of this command is a NuGet package (that is, a .nupkg file).
20
21       If you want to generate a package that contains the debug symbols,  you
22       have two options available:
23
24       · --include-symbols - it creates the symbols package.
25
26       · --include-source  -  it creates the symbols package with a src folder
27         inside containing the source files.
28
29       NuGet dependencies of the packed project are added to the .nuspec file,
30       so  they’re  properly resolved when the package is installed.  Project-
31       to-project references aren’t packaged inside the  project.   Currently,
32       you  must have a package per project if you have project-to-project de‐
33       pendencies.
34
35       By default, dotnet pack builds the project first.  If you wish to avoid
36       this behavior, pass the --no-build option.  This option is often useful
37       in Continuous Integration (CI) build scenarios where you know the  code
38       was previously built.
39
40       You  can  provide MSBuild properties to the dotnet pack command for the
41       packing process.  For more information, see NuGet  metadata  properties
42       and the MSBuild Command-Line Reference.  The Examples section shows how
43       to use the MSBuild -p switch for a couple of different scenarios.
44
45       Web projects aren’t packable by default.  To override the  default  be‐
46       havior, add the following property to your .csproj file:
47
48              <PropertyGroup>
49                 <IsPackable>true</IsPackable>
50              </PropertyGroup>
51
52   Arguments
53       PROJECT | SOLUTION
54
55       The  project or solution to pack.  It’s either a path to a csproj file,
56       a solution file, or to a directory.   If  not  specified,  the  command
57       searches the current directory for a project or solution file.
58

OPTIONS

60       · -c|--configuration {Debug|Release}
61
62         Defines the build configuration.  The default value is Debug.
63
64       · --force
65
66         Forces  all  dependencies to be resolved even if the last restore was
67         successful.  Specifying  this  flag  is  the  same  as  deleting  the
68         project.assets.json file.  Option available since .NET Core 2.0 SDK.
69
70       · -h|--help
71
72         Prints out a short help for the command.
73
74       · --include-source
75
76         Includes  the debug symbols NuGet packages in addition to the regular
77         NuGet packages in the output directory.  The sources  files  are  in‐
78         cluded in the src folder within the symbols package.
79
80       · --include-symbols
81
82         Includes  the debug symbols NuGet packages in addition to the regular
83         NuGet packages in the output directory.
84
85       · --interactive
86
87         Allows the command to stop and wait for user input or action (for ex‐
88         ample,  to  complete  authentication).  Available since .NET Core 3.0
89         SDK.
90
91       · --no-build
92
93         Doesn’t build the project before packing.  It  also  implicitly  sets
94         the --no-restore flag.
95
96       · --no-dependencies
97
98         Ignores  project-to-project  references  and  only  restores the root
99         project.  Option available since .NET Core 2.0 SDK.
100
101       · --no-restore
102
103         Doesn’t execute an implicit restore when running the command.  Option
104         available since .NET Core 2.0 SDK.
105
106       · --nologo
107
108         Doesn’t  display the startup banner or the copyright message.  Avail‐
109         able since .NET Core 3.0 SDK.
110
111       · -o|--output <OUTPUT_DIRECTORY>
112
113         Places the built packages in the directory specified.
114
115       · --runtime <RUNTIME_IDENTIFIER>
116
117         Specifies the target runtime to restore packages for.  For a list  of
118         Runtime  Identifiers  (RIDs),  see the RID catalog.  Option available
119         since .NET Core 2.0 SDK.
120
121       · -s|--serviceable
122
123         Sets the serviceable flag in the package.  For more information,  see
124         .NET  Blog:  .NET  4.5.1 Supports Microsoft Security Updates for .NET
125         NuGet Libraries.
126
127       · --version-suffix <VERSION_SUFFIX>
128
129         Defines the value for the $(VersionSuffix) MSBuild  property  in  the
130         project.
131
132       · -v|--verbosity <LEVEL>
133
134         Sets the verbosity level of the command.  Allowed values are q[uiet],
135         m[inimal], n[ormal], d[etailed], and diag[nostic].
136

EXAMPLES

138       · Pack the project in the current directory:
139
140                dotnet pack
141
142       · Pack the app1 project:
143
144                dotnet pack ~/projects/app1/project.csproj
145
146       · Pack the project in the current directory  and  place  the  resulting
147         packages into the nupkgs folder:
148
149                dotnet pack --output nupkgs
150
151       · Pack  the project in the current directory into the nupkgs folder and
152         skip the build step:
153
154                dotnet pack --no-build --output nupkgs
155
156       · With the project’s version suffix configured as <VersionSuffix>$(Ver‐
157         sionSuffix)</VersionSuffix>  in  the  .csproj  file, pack the current
158         project and update the resulting package version with the given  suf‐
159         fix:
160
161                dotnet pack --version-suffix "ci-1234"
162
163       · Set  the  package  version  to  2.1.0 with the PackageVersion MSBuild
164         property:
165
166                dotnet pack -p:PackageVersion=2.1.0
167
168       · Pack the project for a specific target framework:
169
170                dotnet pack -p:TargetFrameworks=net45
171
172       · Pack the project and use a specific runtime (Windows 10) for the  re‐
173         store operation (.NET Core SDK 2.0 and later versions):
174
175                dotnet pack --runtime win10-x64
176
177       · Pack the project using a .nuspec file:
178
179                dotnet pack ~/projects/app1/project.csproj -p:NuspecFile=~/projects/app1/project.nuspec -p:NuspecBasePath=~/projects/app1/nuget
180
181
182
183                                                        dotnet pack command(1)
Impressum