问题
Are packages now cached in a more shared location somewhere or what?
My solution folder, devoid of any packages
folder:
回答1:
Per project: References->Nuget dictates what packages are referenced and restored. But, as Eastrall mentioned, the packages folder is now global and located in your user folder: C:\Users\[YourUsername]\.nuget\packages
回答2:
To force ./packages folder for Solution
To force download of packages folder to be a child of the solution folder for .NET Core projects, follow these steps:
Create a
NuGet.Config
file in the same directory as the.sln
file.Copy the following contents into the
NuGet.Config
file:
<?xml version="1.0" encoding="utf-8"?> <configuration> <config> <add key="globalPackagesFolder" value=".\packages" /> </config> </configuration>
Configure NuGet to download missing packages by:
3.1. In Visual Studio:
Tools -> Options
3.2. Filter by
nuget
(top left in dialog). SelectGeneral
3.3. Ensure
Allow NuGet to download missing packages
is checked
- Close and re-open the solution. NuGet will download the required packages.
Note: the NuGet.Config configuration can also be achieved by executing the following command from the NuGet Package Manager Console (Tools -> NuGet Package Manager -> Package Manager Console
):
PM> nuget config -set globalPackagesFolder=.\packages -configfile "$(pwd)\NuGet.Config"
回答3:
You still have packages
folder in your .net-core solution, but the global packages are located at: C:\Users\[YourUsername]\.nuget\packages
回答4:
You can check out a question I asked to see if the answers do you any good.
How do I include NuGet packages in my solution for .Net Core projects?
You can get that packages folder back, but you might not be happy with the results, since .Net Core projects rely on so many NuGet packages. Mine is hovering around 1 GB.
https://docs.microsoft.com/en-us/nuget/schema/nuget-config-file#config-section
来源:https://stackoverflow.com/questions/42803195/why-is-there-no-packages-folder-in-my-net-core-solutions-containing-folder