0

With .net core there is one global directory (global cache) that keeps all nuget packages in all Visual Studio 2017 solutions.
We have a .net core solution and we want to get in a specific directory all nuget packages, that this solution depends on.

How can we do this?

We ship our source code with all the dependencies to be able to compile it any time in the future on any server without internet connection etc. Before .net core we just included packages folder inside solution, now with one global packages folder for all solutions it is not possible.

  • https://learn.microsoft.com/en-us/nuget/hosting-packages/local-feeds at least you need a local feed to be set up. – Lex Li Nov 01 '18 at 17:51
  • My idea is to get all referenced packages in a folder and then when we want to build a solution we could just copy these packages to nuget cache on a server (or local feed). But I don't understand how to copy only my referenced packages from my local nuget cache. – kgolovchenko Dec 19 '18 at 10:24

2 Answers2

0

.Net Core How to copy solution nuget packages to specific directory

Just as Lex said, you should create a local feed to store those nuget packages, then make this local feed as package source and add the package to the project from that local package source.

To accomplish this, you can follow my another thread for some more details:

Installing NuGet package located in local package repository into a new Visual Studio Solution

  • Add those packages .nupkg into your local repository folder (Including those versions that are no longer available on the NuGet
    repository).
  • Head into Visual Studio and open the NuGet Settings dialog via Tools NuGet Package Manager > Package Manager Settings. Click the Package Sources tab within the settings dialog, followed by the plus icon in the top left to add a new package source.

  • Enter the Name and Source of your local repository. The name can be any string and will be the name displayed in the NuGet Package
    Manager within Visual Studio.

Besides, you can also copy those packages to the Microsoft Visual Studio Offline Packages folder:

C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

Then add the package to the project from the offline folder.

Once you have installed those packages to the .net core project, those packages would be cached at the global directory.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
0

In .net core we can find all referenced projects by console command

dotnet list package

see https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-list-package for more details. Next we can go to nuget global packages folder and copy all these packages to desired folder.