Set a NuGet package type
With NuGet 3.5+, packages can be marked with a specific package type to indicate its intended use. Packages not marked with a type, including all packages created with earlier versions of NuGet, default to the Dependency
type.
Dependency
type packages add build- or run-time assets to libraries and applications, and can be installed in any project type (assuming they are compatible).DotnetTool
type packages are extensions to the dotnet CLI and are invoked from the command line. Such packages can be installed only in .NET Core projects and have no effect on restore operations. More details about these per-project extensions are available in the .NET Core extensibility documentation.Template
type packages provide custom templates that can be used to create files or projects like an app, service, tool, or class library.Custom type packages use an arbitrary type identifier that conforms to the same format rules as package IDs. Any type other than
Dependency
andDotnetTool
, however, are not recognized by the NuGet Package Manager in Visual Studio.
Package types are set in the .nuspec
file. It's best for backwards compatibility to not explicitly set the Dependency
type and to instead rely on NuGet assuming this type when no type is specified.
.nuspec
: Indicate the package type within apackageTypes\packageType
node under the<metadata>
element:<?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <metadata> <!-- ... --> <packageTypes> <packageType name="DotnetTool" /> </packageTypes> </metadata> </package>