You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/consume-packages/Package-Restore.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,11 +28,11 @@ You can trigger Package Restore in any of the following ways:
28
28
29
29
-**Visual Studio**: In Visual Studio on Windows, use one of the following methods.
30
30
31
-
- Restore packages automatically. Package Restore happens automatically when you create a project from a template or build a project, subject to the options in [Enable and disable package restore](#enable-and-disable-package-restore-visual-studio). In NuGet 4.0+, restore also happens automatically when you make changes to a .NET Core SDK-based project.
31
+
- Restore packages automatically. Package Restore happens automatically when you create a project from a template or build a project, subject to the options in [Enable and disable package restore](#enable-and-disable-package-restore-visual-studio). In NuGet 4.0+, restore also happens automatically when you make changes to a SDK-style project (typically a .NET Core or .NET Standard project).
32
32
33
33
- Restore packages manually. To restore manually, right-click the solution in **Solution Explorer** and select **Restore NuGet Packages**. If one or more individual packages still aren't installed properly, **Solution Explorer** shows an error icon. Right-click and select **Manage NuGet Packages**, and use **Package Manager** to uninstall and reinstall the affected packages. For more information, see [Reinstall and update packages](../consume-packages/reinstalling-and-updating-packages.md)
34
34
35
-
If you see the error "This project references NuGet package(s) that are missing on this computer," or "One or more NuGet packages need to be restored but couldn't be because consent has not been granted," [enable automatic restore](#enable-and-disable-package-restore-visual-studio). Also see [Package Restore troubleshooting](Package-restore-troubleshooting.md).
35
+
If you see the error "This project references NuGet package(s) that are missing on this computer," or "One or more NuGet packages need to be restored but couldn't be because consent has not been granted," [enable automatic restore](#enable-and-disable-package-restore-visual-studio). Also, see[Migrate to automatic package restore](#migrate-to-automatic-package-restore-visual-studio) and[Package Restore troubleshooting](Package-restore-troubleshooting.md).
36
36
37
37
-**dotnet CLI**: In the command line, switch to the folder that contains your project, and then use the [dotnet restore](/dotnet/core/tools/dotnet-restore?tabs=netcore2x) command to restore packages listed in the project file with [PackageReference](../consume-packages/package-references-in-project-files.md). With .NET Core 2.0 and later, restore happens automatically with the `dotnet build` and `dotnet run` commands.
38
38
@@ -120,6 +120,25 @@ To avoid using the cache for HTTP sources, do one of the following:
120
120
- Clear the cache using `nuget locals http-cache -clear` or `dotnet nuget locals http-cache --clear`.
121
121
- Temporarily set the NUGET_HTTP_CACHE_PATH environment variable to a different folder.
122
122
123
+
## Migrate to automatic package restore (Visual Studio)
124
+
125
+
For NuGet 2.6 and earlier, an MSBuild-integrated package restore was previously supported but that is no longer true. (It was typically enabled by right-clicking a solution in Visual Studio and selecting **Enable NuGet Package Restore**). If your project uses the deprecated MSBuild-integrated package restore, please migrate to automatic package restore.
126
+
127
+
Projects that use MSBuild-Integrated package restore typically contain a *.nuget* folder with three files: *NuGet.config*, *nuget.exe*, and *NuGet.targets*. The presence of a *NuGet.targets* file determines whether NuGet will continue to use the MSBuild-untegrated approach, so this file must be removed during the migration.
128
+
129
+
To migrate to automatic package restore:
130
+
131
+
1. Close Visual Studio.
132
+
2. Delete *.nuget/nuget.exe* and *.nuget/NuGet.targets*.
133
+
3. For each project file, remove the `<RestorePackages>` element and remove any reference to *NuGet.targets*.
134
+
135
+
To test the automatic package restore:
136
+
137
+
1. Remove the *packages* folder from the solution.
138
+
2. Open the solution in Visual Studio and start a build.
139
+
140
+
Automatic package restore should download and install each dependency package, without adding them to source control.
141
+
123
142
## Troubleshooting
124
143
125
144
See [Troubleshoot package restore](package-restore-troubleshooting.md).
Copy file name to clipboardExpand all lines: docs/consume-packages/Package-restore-troubleshooting.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ If you're using Visual Studio, first enable package restore as follows. Otherwis
24
24
25
25

26
26
27
-
These settings can also be changed in your `NuGet.config` file; see the [consent](#consent) section.
27
+
These settings can also be changed in your `NuGet.config` file; see the [consent](#consent) section. If your project is an older project that uses the MSBuild-integrated package restore, you may need to [migrate](package-restore.md#migrate-to-automatic-package-restore-visual-studio) to automatic package restore.
0 commit comments