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

dotnet pack

NAME

7       dotnet pack - Packs the code into a NuGet package.
8

SYNOPSIS

10   .NET Core 2.x
11              dotnet pack [<PROJECT>] [-c|--configuration] [--force] [--include-source] [--include-symbols] [--no-build] [--no-dependencies]
12                  [--no-restore] [-o|--output] [--runtime] [-s|--serviceable] [-v|--verbosity] [--version-suffix]
13              dotnet pack [-h|--help]
14
15   .NET Core 1.x
16              dotnet pack [<PROJECT>] [-c|--configuration] [--include-source] [--include-symbols] [--no-build] [-o|--output]
17                  [-s|--serviceable] [-v|--verbosity] [--version-suffix]
18              dotnet pack [-h|--help]
19
20          *   *   *   *   *
21

DESCRIPTION

23       The  dotnet pack command builds the project and creates NuGet packages.
24       The result of this command is a NuGet package.  If  the  --include-sym‐
25       bols option is present, another package containing the debug symbols is
26       created.
27
28       NuGet dependencies of the packed project are added to the .nuspec file,
29       so  they’re  properly resolved when the package is installed.  Project-
30       to-project references aren’t packaged inside the  project.   Currently,
31       you  must have a package per project if you have project-to-project de‐
32       pendencies.
33
34       By default, dotnet pack builds the project first.  If you wish to avoid
35       this behavior, pass the --no-build option.  This option is often useful
36       in Continuous Integration (CI) build scenarios where you know the  code
37       was previously built.
38
39       You  can  provide MSBuild properties to the dotnet pack command for the
40       packing process.  For more information, see NuGet  metadata  properties
41       and the MSBuild Command-Line Reference.  The Examples section shows how
42       to use the MSBuild -p switch for a couple of different scenarios.
43
44   Arguments
45       · PROJECT
46
47         The project to pack.  It’s either a path to a csproj file or to a di‐
48         rectory.  If not specified, it defaults to the current directory.
49

OPTIONS

51   .NET Core 2.x
52       · -c|--configuration {Debug|Release}
53
54         Defines the build configuration.  The default value is Debug.
55
56       · --force
57
58         Forces  all  dependencies to be resolved even if the last restore was
59         successful.  Specifying  this  flag  is  the  same  as  deleting  the
60         project.assets.json file.
61
62       · -h|--help
63
64         Prints out a short help for the command.
65
66       · --include-source
67
68         Includes  the  source  files in the NuGet package.  The sources files
69         are included in the src folder within the nupkg.
70
71       · --include-symbols
72
73         Generates the symbols nupkg.
74
75       · --no-build
76
77         Doesn’t build the project before packing.  It  also  implicitly  sets
78         the --no-restore flag.
79
80       · --no-dependencies
81
82         Ignores  project-to-project  references  and  only  restores the root
83         project.
84
85       · --no-restore
86
87         Doesn’t execute an implicit restore when running the command.
88
89       · -o|--output <OUTPUT_DIRECTORY>
90
91         Places the built packages in the directory specified.
92
93       · --runtime <RUNTIME_IDENTIFIER>
94
95         Specifies the target runtime to restore packages for.  For a list  of
96         Runtime Identifiers (RIDs), see the RID catalog.
97
98       · -s|--serviceable
99
100         Sets  the serviceable flag in the package.  For more information, see
101         .NET Blog: .NET 4.5.1 Supports Microsoft Security  Updates  for  .NET
102         NuGet Libraries.
103
104       · --version-suffix <VERSION_SUFFIX>
105
106         Defines  the  value  for the $(VersionSuffix) MSBuild property in the
107         project.
108
109       · -v|--verbosity <LEVEL>
110
111         Sets the verbosity level of the command.  Allowed values are q[uiet],
112         m[inimal], n[ormal], d[etailed], and diag[nostic].
113
114         [!NOTE] Web projects aren’t packable by default.  To override the de‐
115         fault behavior, add the following property to your .csproj file:
116
117                <PropertyGroup>
118                   <IsPackable>true</IsPackable>
119                </PropertyGroup>
120
121   .NET Core 1.x
122       · -c|--configuration {Debug|Release}
123
124         Defines the build configuration.  The default value is Debug.
125
126       · -h|--help
127
128         Prints out a short help for the command.
129
130       · --include-source
131
132         Includes the source files in the NuGet package.   The  sources  files
133         are included in the src folder within the nupkg.
134
135       · --include-symbols
136
137         Generates the symbols nupkg.
138
139       · --no-build
140
141         Doesn’t build the project before packing.
142
143       · -o|--output <OUTPUT_DIRECTORY>
144
145         Places the built packages in the directory specified.
146
147       · -s|--serviceable
148
149         Sets  the serviceable flag in the package.  For more information, see
150         .NET Blog: .NET 4.5.1 Supports Microsoft Security  Updates  for  .NET
151         NuGet Libraries.
152
153       · --version-suffix <VERSION_SUFFIX>
154
155         Defines  the  value  for the $(VersionSuffix) MSBuild property in the
156         project.
157
158       · -v|--verbosity <LEVEL>
159
160         Sets the verbosity level of the command.  Allowed values are q[uiet],
161         m[inimal], n[ormal], d[etailed], and diag[nostic].
162
163          *   *   *   *   *
164

EXAMPLES

166       · Pack the project in the current directory:
167
168                dotnet pack
169
170       · Pack the app1 project:
171
172                dotnet pack ~/projects/app1/project.csproj
173
174       · Pack  the  project  in  the current directory and place the resulting
175         packages into the nupkgs folder:
176
177                dotnet pack --output nupkgs
178
179       · Pack the project in the current directory into the nupkgs folder  and
180         skip the build step:
181
182                dotnet pack --no-build --output nupkgs
183
184       · With the project’s version suffix configured as <VersionSuffix>$(Ver‐
185         sionSuffix)</VersionSuffix> in the .csproj  file,  pack  the  current
186         project  and update the resulting package version with the given suf‐
187         fix:
188
189                dotnet pack --version-suffix "ci-1234"
190
191       · Set the package version to  2.1.0  with  the  PackageVersion  MSBuild
192         property:
193
194                dotnet pack -p:PackageVersion=2.1.0
195
196       · Pack the project for a specific target framework:
197
198                dotnet pack -p:TargetFrameworks=net45
199
200       · Pack  the project and use a specific runtime (Windows 10) for the re‐
201         store operation (.NET Core SDK 2.0 and later versions):
202
203                dotnet pack --runtime win10-x64
204
205       · Pack the project using a .nuspec file:
206
207                dotnet pack ~/projects/app1/project.csproj /p:NuspecFile=~/projects/app1/project.nuspec /p:NuspecBasePath=~/projects/app1/nuget
208
209
210
211                                                        dotnet pack command(1)
Impressum