NuGet supports multiple feeds, running against either a server or a simple folder / fileshare. See Phil Haack's post explaining both options for more information. I'm a big believer in running your own local NuGet feed for a lot of reasons - offline access, control over updates, and as an absolute must-have for demonstrations and training. I previously wrote up a NuGet Powershell script which pages through the NuGet OData feed and downloads local copies of the packages. It's a little more complex than you'd guess, since the script needs to follow redirections and page links, plus I added in some options to skip downloads for features you've got, only grab the most popular X packages, etc.
I'd always assumed this would end up as a NuGet package, although the use case is a little out of the ordinary. The primary use case of NuGet is to add things (libraries, code, and content) to an existing application, and this NuGet package doesn't work at the project level at all. But, it's just so handy - and there had been enough requests for it - that I couldn't help myself.
I'd actually started on this when Eric Hexter mentioned that he was working on it as well, so I merged what he'd done, removed all the affiliate ad codes he'd snuck in, and uploaded it yesterday. So, here's NuGet.Downloader.
How to use it
- Open a project in Visual Studio (it doesn't matter which - if you try to install a package outside of a solution, you'll get slapped down with "The current environment doesn't have a solution open").
- Open the Package Manager console (View / Other Windows / Package Manager Console).
- Type "install-package NuGet.Downloader" - you should see "Successfully installed 'Nuget.Downloader 184.108.40.206'." (with whatever the current version number is).
- This adds a new commend to the Package Manager console, Download-Packages. You can run it without any parameters, which will grab the top 500 most popular NuGet packages and drop them in a new LocalNuGet folder inside your My Documents folder.
- If desired, uninstall the package using Uninstall-Package.
- feedBaseUrl (default: official NuGet package feed, following redirections) - you can point this at a corporate NuGet server or some other location
- latest (default: $true) - when true, only grabs the latest version of each package
- overwrite (default: $false) - when true, downloads and overwrites all packages regardless of whether you already have a copy
- top (default: 500) - number of packages to download, ordered by package popularity. If $null, downloads all packages; if 1 it would download the most popular package
- destinationDirectory - (default: %HOMEPATH%\Documents\NuGetLocal) full path to the directory you'd like the packages downloaded to. Note: I changed this from LocalNuGet in the Powershell to NuGetLocal in the package, as I thought it made more sense
Example - downloading the top 10 most popular packages with overwrite option, then removing the package:
PM> Install-Package NuGet.Downloader Successfully installed 'Nuget.Downloader 220.127.116.11'. PM> Download-Packages -top 10 -overwrite $true Downloading latest 10 packages (by download count) downloading from http://packages.nuget.org/v1/FeedService.svc/Packages?$filter=IsLatestVersion eq true&$orderby=DownloadCount desc&$top=10 Complete. Local packages saved to C:\Users\Jon\Documents\NuGetLocal
PM> Uninstall-Package NuGet.Downloader Successfully uninstalled 'Nuget.Downloader 18.104.22.168'. PM>
Hope it helps you out, and please let me know how I can make it better.