dotnet-add-package - Man Page

Adds a package reference to a project file.

dotnet add package

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


dotnet add [<PROJECT>] package <PACKAGE_NAME> [-h|--help] [-f|--framework] [--interactive] [-n|--no-restore] [--package-directory] [-s|--source] [-v|--version]


The dotnet add package command provides a convenient option to add a package reference to a project file. After running the command, there’s a compatibility check to ensure the package is compatible with the frameworks in the project. If the check passes, a <PackageReference> element is added to the project file and dotnet restore is run.

For example, adding Newtonsoft.Json to ToDo.csproj produces output similar to the following example:

  Writing C:\Users\mairaw\AppData\Local\Temp\tmp95A8.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project 'C:\projects\ToDo\ToDo.csproj'.
log  : Restoring packages for C:\Temp\projects\consoleproj\consoleproj.csproj...
info :   GET
info :   OK 79ms
info :   GET
info :   OK 232ms
log  : Installing Newtonsoft.Json 12.0.1.
info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'C:\projects\ToDo\ToDo.csproj'.
info : PackageReference for package 'Newtonsoft.Json' version '12.0.1' added to file 'C:\projects\ToDo\ToDo.csproj'.

The ToDo.csproj file now contains a <PackageReference> element for the referenced package.

<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />



    Specifies the project file. If not specified, the command searches the current directory for one.


    The package reference to add.



See also

  • Managing the global packages, cache, and temp folders in NuGet
  • NuGet package versioning


.NET Core