2

I have Visual Studio 2017 solution with several Nuget packages referenced. I want build that solution on the computer not connected to the internet. So I will not able download Nuget packages. I want download all Nuget packages referenced in my solution as *.nupkg files and then specify local folder with these files as packges source (Tools -> Options -> NuGet Package Manager -> Package Sources).

I don't want download the packages manually, so number of ones is significant.

I aware about <UserFolder>\.nuget\packages folder, but that folder contains all packages ever downloaded for the all solutions. I need packages for specific solution only.

Igor Buchelnikov
  • 505
  • 4
  • 14
  • 3
    A simple hack here would be to rename the .nuget/packages folder to something else then restore the solution. Then copy the .nuget/packages folder to some other location and create a package source that points to copied folder. – Matt Ward Dec 17 '19 at 13:26
  • 2
    Hi Matt, that is the good answer and l suggest you could add an answer for this issue and it will help lgor and other community members handle similar issues.Thanks in advance. – Mr Qian Dec 18 '19 at 03:38
  • Renaming the package(just like [clean the nuget cache](https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders#clearing-local-folders))folder is just to download only the nuget packages needed for the current solution in packages folder because the default VS recovery packages are all downloaded into [the global cache](https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders) `%userprofile%\.nuget\packages`. – Mr Qian Dec 18 '19 at 05:53
  • After that, you can copy the folder into the target PC,add the path into package source. By doing all of the above, you can successfully build your project. – Mr Qian Dec 18 '19 at 05:57

1 Answers1

3

This question is pretty much a duplicate of a question from a year ago, where I posted an answer that is conceptually the same as what Matt Ward suggested. The difference is that instead of renaming your global packages folder, you use nuget.config to specify a different location.

zivkan
  • 12,793
  • 2
  • 34
  • 51