
This topic applies to: ✓ .NET Core SDK 1.x ✓ .NET Core SDK 2.x
Name
dotnet pack - Packs the code into a NuGet package.
Synopsis



.NET Core 2.x


.NET Core 1.x



dotnet pack [&lt;PROJECT&gt;] [-c|--configuration] [--force] [--include-source] [--include-symbols] [--no-build] [--no-dependencies] [--no-restore] [-o|--output] [--runtime] [-s|--serviceable] [-v|--verbosity] [--version-suffix]
dotnet pack [-h|--help]


dotnet pack [&lt;PROJECT&gt;] [-c|--configuration] [--include-source] [--include-symbols] [--no-build] [-o|--output] [-s|--serviceable] [-v|--verbosity] [--version-suffix]
dotnet pack [-h|--help]


Description
The dotnet pack command builds the project and creates NuGet packages. The result of this command is a NuGet package. If the --include-symbols option is present, another package containing the debug symbols is created.
NuGet dependencies of the packed project are added to the .nuspec file, so they&#39;re properly resolved when the package is installed. Project-to-project references aren&#39;t packaged inside the project. Currently, you must have a package per project if you have project-to-project dependencies.
By default, dotnet pack builds the project first. If you wish to avoid this behavior, pass the --no-build option. This is often useful in Continuous Integration (CI) build scenarios where you know the code was previously built.
You can provide MSBuild properties to the dotnet pack command for the packing process. For more information, see NuGet metadata properties and the MSBuild Command-Line Reference. The Examples section shows how to use the MSBuild /p switch for a couple of different scenarios.
Arguments
PROJECT
The project to pack. It&#39;s either a path to a csproj file or to a directory. If omitted, it defaults to the current directory.
Options



.NET Core 2.x


.NET Core 1.x



-c|--configuration {Debug|Release}
Defines the build configuration. The default value is Debug.
--force
Forces all dependencies to be resolved even if the last restore was successful. This is equivalent to deleting the project.assets.json file.
-h|--help
Prints out a short help for the command.
--include-source
Includes the source files in the NuGet package. The sources files are included in the src folder within the nupkg.
--include-symbols
Generates the symbols nupkg.
--no-build
Doesn&#39;t build the project before packing.
--no-dependencies
Ignores project-to-project references and only restores the root project.
--no-restore
Doesn&#39;t perform an implicit restore when running the command.
-o|--output &lt;OUTPUT_DIRECTORY&gt;
Places the built packages in the directory specified.
-r|--runtime &lt;RUNTIME_IDENTIFIER&gt;
Specifies the target runtime to restore packages for. For a list of Runtime Identifiers (RIDs), see the RID catalog.
-s|--serviceable
Sets the serviceable flag in the package. For more information, see .NET Blog: .NET 4.5.1 Supports Microsoft Security Updates for .NET NuGet Libraries.
--version-suffix &lt;VERSION_SUFFIX&gt;
Defines the value for the $(VersionSuffix) MSBuild property in the project.
-v|--verbosity &lt;LEVEL&gt;
Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].


-c|--configuration {Debug|Release}
Defines the build configuration. The default value is Debug.
-h|--help
Prints out a short help for the command.
--include-source
Includes the source files in the NuGet package. The sources files are included in the src folder within the nupkg.
--include-symbols
Generates the symbols nupkg.
--no-build
Doesn&#39;t build the project before packing.
-o|--output &lt;OUTPUT_DIRECTORY&gt;
Places the built packages in the directory specified.
-s|--serviceable
Sets the serviceable flag in the package. For more information, see .NET Blog: .NET 4.5.1 Supports Microsoft Security Updates for .NET NuGet Libraries.
--version-suffix &lt;VERSION_SUFFIX&gt;
Defines the value for the $(VersionSuffix) MSBuild property in the project.
-v|--verbosity &lt;LEVEL&gt;
Sets the verbosity level of the command. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].


Examples
Pack the project in the current directory:
dotnet pack
Pack the app1 project:
dotnet pack ~/projects/app1/project.csproj
Pack the project in the current directory and place the resulting packages into the nupkgs folder:
dotnet pack --output nupkgs
Pack the project in the current directory into the nupkgs folder and skip the build step:
dotnet pack --no-build --output nupkgs
With the project&#39;s version suffix configured as &lt;VersionSuffix&gt;$(VersionSuffix)&lt;/VersionSuffix&gt; in the .csproj file, pack the current project and update the resulting package version with the given suffix:
dotnet pack --version-suffix &quot;ci-1234&quot;
Set the package version to 2.1.0 with the PackageVersion MSBuild property:
dotnet pack /p:PackageVersion=2.1.0
Pack the project for a specific target framework:
dotnet pack /p:TargetFrameworks=net45
