Skip to content

Commit b355b1d

Browse files
authored
Merge pull request NuGet#1525 from NuGet/mikejo-issues
Fix to issue #993
2 parents 80f6b82 + 31d3808 commit b355b1d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

docs/consume-packages/Package-Restore.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ You can trigger Package Restore in any of the following ways:
2828

2929
- **Visual Studio**: In Visual Studio on Windows, use one of the following methods.
3030

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).
3232

3333
- 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)
3434

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).
3636

3737
- **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.
3838

@@ -120,6 +120,25 @@ To avoid using the cache for HTTP sources, do one of the following:
120120
- Clear the cache using `nuget locals http-cache -clear` or `dotnet nuget locals http-cache --clear`.
121121
- Temporarily set the NUGET_HTTP_CACHE_PATH environment variable to a different folder.
122122

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+
123142
## Troubleshooting
124143

125144
See [Troubleshoot package restore](package-restore-troubleshooting.md).

docs/consume-packages/Package-restore-troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If you're using Visual Studio, first enable package restore as follows. Otherwis
2424

2525
![Enable NuGet package restore in Tool/Options](../consume-packages/media/restore-01-autorestoreoptions.png)
2626

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.
2828

2929
<a name="missing"></a>
3030

0 commit comments

Comments
 (0)