1dotnet-restore(1)             .NET Documentation             dotnet-restore(1)
2
3
4

dotnet restore

6       This article applies to: ✔️ .NET Core 3.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
28dotnet new
29
30dotnet build
31
32dotnet build-server
33
34dotnet run
35
36dotnet test
37
38dotnet publish
39
40dotnet 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              Signed package verification during restore operations requires a
50              certificate  root  store that is valid for both code signing and
51              timestamping.  See NuGet signed  package  verification  for  de‐
52              tails.
53
54   Specify feeds
55       To  restore  the dependencies, NuGet needs the feeds where the packages
56       are located.  Feeds are usually provided via the nuget.config  configu‐
57       ration  file.   A  default configuration file is provided when the .NET
58       SDK is installed.  To specify additional feeds, do one of  the  follow‐
59       ing:
60
61       • Create your own nuget.config file in the project directory.  For more
62         information, see Common NuGet configurations and nuget.config differ‐
63         ences later in this article.
64
65       • Use dotnet nuget commands such as dotnet nuget add source.
66
67       You can override the nuget.config feeds with the -s option.
68
69       For  information  about  how  to use authenticated feeds, see Consuming
70       packages from authenticated feeds.
71
72   Global packages folder
73       For dependencies, you can  specify  where  the  restored  packages  are
74       placed  during the restore operation using the --packages argument.  If
75       not specified, the default NuGet package cache is used, which is  found
76       in  the  .nuget/packages  directory in the user’s home directory on all
77       operating systems.  For example, /home/user1 on Linux or C: on Windows.
78
79   Project-specific tooling
80       For project-specific tooling, dotnet restore first restores the package
81       in  which  the  tool is packed, and then proceeds to restore the tool’s
82       dependencies as specified in its project file.
83
84   nuget.config differences
85       The behavior of the dotnet restore command is affected by the  settings
86       in the nuget.config file, if present.  For example, setting the global‐
87       PackagesFolder in nuget.config places the restored  NuGet  packages  in
88       the specified folder.  This is an alternative to specifying the --pack‐
89       ages option on the dotnet restore command.  For more  information,  see
90       the nuget.config reference.
91
92       There are three specific settings that dotnet restore ignores:
93
94       • bindingRedirects
95
96         Binding  redirects  don’t  work  with <PackageReference> elements and
97         .NET only supports <PackageReference> elements for NuGet packages.
98
99       • solution
100
101         This setting is Visual Studio specific and  doesn’t  apply  to  .NET.
102         .NET doesn’t use a packages.config file and instead uses <PackageRef‐
103         erence> elements for NuGet packages.
104
105       • trustedSigners
106
107         Support for cross-platform package signature verification  was  added
108         in the .NET 5.0.100 SDK.
109
110   Workload manifest downloads
111       When  you  run  this  command,  it initiates an asynchronous background
112       download of advertising manifests for workloads.  If  the  download  is
113       still running when this command finishes, the download is stopped.  For
114       more information, see Advertising manifests.
115

ARGUMENTS

117ROOT
118
119         Optional path to the project file to restore.
120

OPTIONS

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

EXAMPLES

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