1(1)                                  .NET                                  (1)
2
3
4

dotnet restore

6       This article applies to: ✔️ .NET Core 2.1 SDK and later versions
7

NAME

9       dotnet restore - Restores the dependencies and tools of a project.
10

SYNOPSIS

12              dotnet restore [<ROOT>] [--configfile <FILE>] [--disable-parallel]
13                  [-f|--force] [--force-evaluate] [--ignore-failed-sources]
14                  [--interactive] [--lock-file-path <LOCK_FILE_PATH>] [--locked-mode]
15                  [--no-cache] [--no-dependencies] [--packages <PACKAGES_DIRECTORY>]
16                  [-r|--runtime <RUNTIME_IDENTIFIER>] [-s|--source <SOURCE>]
17                  [--use-lock-file] [-v|--verbosity <LEVEL>]
18
19              dotnet restore -h|--help
20

DESCRIPTION

22       The  dotnet  restore command uses NuGet to restore dependencies as well
23       as project-specific tools that are specified in the project  file.   In
24       most  cases,  you  don’t need to explicitly use the dotnet restore com‐
25       mand, since a NuGet restore is run implicitly if necessary when you run
26       the following commands:
27
28       • dotnet new
29
30       • dotnet build
31
32       • dotnet build-server
33
34       • dotnet run
35
36       • dotnet test
37
38       • dotnet publish
39
40       • dotnet pack
41
42       Sometimes,  it  might be inconvenient to run the implicit NuGet restore
43       with these commands.  For example,  some  automated  systems,  such  as
44       build  systems,  need to call dotnet restore explicitly to control when
45       the restore occurs so that they can control network usage.  To  prevent
46       the  implicit NuGet restore, you can use the --no-restore flag with any
47       of these commands to disable implicit restore.
48
49   Specify feeds
50       To restore the dependencies, NuGet needs the feeds where  the  packages
51       are  located.  Feeds are usually provided via the nuget.config configu‐
52       ration file.  A default configuration file is provided  when  the  .NET
53       SDK  is  installed.  To specify additional feeds, do one of the follow‐
54       ing:
55
56       • Create your own nuget.config file in the project directory.  For more
57         information, see Common NuGet configurations and nuget.config differ‐
58         ences later in this article.
59
60       • Use dotnet nuget commands such as dotnet nuget add source.
61
62       You can override the nuget.config feeds with the -s option.
63
64       For information about how to use  authenticated  feeds,  see  Consuming
65       packages from authenticated feeds.
66
67   Global packages folder
68       For  dependencies,  you  can  specify  where  the restored packages are
69       placed during the restore operation using the --packages argument.   If
70       not  specified, the default NuGet package cache is used, which is found
71       in the .nuget/packages directory in the user’s home  directory  on  all
72       operating systems.  For example, /home/user1 on Linux or C: on Windows.
73
74   Project-specific tooling
75       For project-specific tooling, dotnet restore first restores the package
76       in which the tool is packed, and then proceeds to  restore  the  tool’s
77       dependencies as specified in its project file.
78
79   nuget.config differences
80       The  behavior of the dotnet restore command is affected by the settings
81       in the nuget.config file, if present.  For example, setting the global‐
82       PackagesFolder  in  nuget.config  places the restored NuGet packages in
83       the specified folder.  This is an alternative to specifying the --pack‐
84       ages  option  on the dotnet restore command.  For more information, see
85       the nuget.config reference.
86
87       There are three specific settings that dotnet restore ignores:
88
89       • bindingRedirects
90
91         Binding redirects don’t work  with  <PackageReference>  elements  and
92         .NET only supports <PackageReference> elements for NuGet packages.
93
94       • solution
95
96         This  setting  is  Visual  Studio specific and doesn’t apply to .NET.
97         .NET doesn’t use a packages.config file and instead uses <PackageRef‐
98         erence> elements for NuGet packages.
99
100       • trustedSigners
101
102         Support  for  cross-platform package signature verification was added
103         in the .NET 5.0.100 SDK.
104
105   Workload manifest downloads
106       When you run this command,  it  initiates  an  asynchronous  background
107       download  of  advertising  manifests for workloads.  If the download is
108       still running when this command finishes, the download is stopped.  For
109       more information, see Advertising manifests.
110
111   Arguments
112ROOT
113
114         Optional path to the project file to restore.
115

OPTIONS

117--configfile <FILE>
118
119         The  NuGet  configuration  file (nuget.config) to use.  If specified,
120         only the settings from this file will be used.  If not specified, the
121         hierarchy  of  configuration files from the current directory will be
122         used.  For more information, see Common NuGet Configurations.
123
124--disable-parallel
125
126         Disables restoring multiple projects in parallel.
127
128--force
129
130         Forces all dependencies to be resolved even if the last  restore  was
131         successful.   Specifying  this  flag  is  the  same  as  deleting the
132         project.assets.json file.
133
134--force-evaluate
135
136         Forces restore to reevaluate all dependencies even if a lock file al‐
137         ready exists.
138
139-?|-h|--help
140
141         Prints out a description of how to use the command.
142
143--ignore-failed-sources
144
145         Only warn about failed sources if there are packages meeting the ver‐
146         sion requirement.
147
148--interactive
149
150         Allows the command to stop and wait for user input  or  action.   For
151         example, to complete authentication.
152
153--lock-file-path <LOCK_FILE_PATH>
154
155         Output location where project lock file is written.  By default, this
156         is PROJECT_ROOT.lock.json.
157
158--locked-mode
159
160         Don’t allow updating project lock file.
161
162--no-cache
163
164         Specifies to not cache HTTP requests.
165
166--no-dependencies
167
168         When restoring a project with  project-to-project  (P2P)  references,
169         restores the root project and not the references.
170
171--packages <PACKAGES_DIRECTORY>
172
173         Specifies the directory for restored packages.
174
175-r|--runtime <RUNTIME_IDENTIFIER>
176
177         Specifies a runtime for the package restore.  This is used to restore
178         packages for runtimes not explicitly listed  in  the  <RuntimeIdenti‐
179         fiers>  tag  in  the .csproj file.  For a list of Runtime Identifiers
180         (RIDs), see the RID catalog.  Provide  multiple  RIDs  by  specifying
181         this option multiple times.
182
183-s|--source <SOURCE>
184
185         Specifies  the  URI of the NuGet package source to use during the re‐
186         store operation.  This setting overrides all of the sources specified
187         in the nuget.config files.  Multiple sources can be provided by spec‐
188         ifying this option multiple times.
189
190--use-lock-file
191
192         Enables project lock file to be generated and used with restore.
193
194-v|--verbosity <LEVEL>
195
196         Sets the verbosity level of the command.  Allowed values are q[uiet],
197         m[inimal],  n[ormal],  d[etailed],  and diag[nostic].  The default is
198         minimal.   For  more  information,  see  <xref:Microsoft.Build.Frame‐
199         work.LoggerVerbosity>.
200

EXAMPLES

202       • Restore  dependencies and tools for the project in the current direc‐
203         tory:
204
205                dotnet restore
206
207       • Restore dependencies and tools for the app1 project found in the giv‐
208         en path:
209
210                dotnet restore ./projects/app1/app1.csproj
211
212       • Restore the dependencies and tools for the project in the current di‐
213         rectory using the file path provided as the source:
214
215                dotnet restore -s c:\packages\mypackages
216
217       • Restore the dependencies and tools for the project in the current di‐
218         rectory using the two file paths provided as sources:
219
220                dotnet restore -s c:\packages\mypackages -s c:\packages\myotherpackages
221
222       • Restore  dependencies and tools for the project in the current direc‐
223         tory showing detailed output:
224
225                dotnet restore --verbosity detailed
226
227
228
229                                                                           (1)
Impressum