1dotnet add package command - .NETdCoo.trNneEeTtCLCaIod(rd1e)package command - .NET Core CLI(1)
2
3
4

dotnet add package

NAME

7       dotnet add package - Adds a package reference to a project file.
8

SYNOPSIS

10       dotnet add [<PROJECT>] package <PACKAGE_NAME> [-h|--help] [-f|--frame‐
11       work] [-n|--no-restore] [--package-directory] [-s|--source] [-v|--ver‐
12       sion]
13

DESCRIPTION

15       The  dotnet add package  command  provides a convenient option to add a
16       package reference to  a  project  file.   After  running  the  command,
17       there's  a compatibility check to ensure the package is compatible with
18       the frameworks in the project.  If the check passes,  a  <PackageRefer‐
19       ence> element is added to the project file and dotnet restore is run.
20
21       For example, adding Newtonsoft.Json to ToDo.csproj produces output sim‐
22       ilar to the following example:
23
24                Writing C:\Users\mairaw\AppData\Local\Temp\tmp95A8.tmp
25              info : Adding PackageReference for package 'Newtonsoft.Json' into project 'C:\projects\ToDo\ToDo.csproj'.
26              log  : Restoring packages for C:\projects\ToDo\ToDo.csproj...
27              info :   GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
28              info :   OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 235ms
29              info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'C:\projects\ToDo\ToDo.csproj'.
30              info : PackageReference for package 'Newtonsoft.Json' version '10.0.3' added to file 'C:\projects\ToDo\ToDo.csproj'.
31
32       The ToDo.csproj file now contains a <PackageReference> element for  the
33       referenced package.
34
35              <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
36
37   Arguments
38       PROJECT
39
40       Specifies the project file.  If not specified, the command searches the
41       current directory for one.
42
43       PACKAGE_NAME
44
45       The package reference to add.
46

OPTIONS

48       -h|--help
49
50       Prints out a short help for the command.
51
52       -f|--framework <FRAMEWORK>
53
54       Adds a package reference only when targeting a specific framework.
55
56       -n|--no-restore
57
58       Adds a package reference without performing a restore preview and  com‐
59       patibility check.
60
61       --package-directory <PACKAGE_DIRECTORY>
62
63       Restores the package to the specified directory.
64
65       -s|--source <SOURCE>
66
67       Uses a specific NuGet package source during the restore operation.
68
69       -v|--version <VERSION>
70
71       Version of the package.
72

EXAMPLES

74       Add Newtonsoft.Json NuGet package to a project:
75
76       dotnet add package Newtonsoft.Json
77
78       Add a specific version of a package to a project:
79
80       dotnet add ToDo.csproj package Microsoft.Azure.DocumentDB.Core -v 1.0.0
81
82       Add a package using a specific NuGet source:
83
84       dotnet add package Microsoft.AspNetCore.StaticFiles -s https://dot
85       net.myget.org/F/dotnet-core/api/v3/index.json
86

AUTHORS

88       mairaw.
89
90
91
92                                 dotnet add package command - .NET Core CLI(1)
Impressum