void DownloadPackage(IPackage package, string fullPathToDownloadTo, NuGet.PackageDownloader directDownloader)
{
Log.VerboseFormat("Found package {0} version {1}", package.Id, package.Version);
Log.Verbose("Downloading to: " + fullPathToDownloadTo);
var dsp = package as DataServicePackage;
if (dsp != null && directDownloader != null)
{
Log.Verbose("A direct download is possible; bypassing the NuGet machine cache");
using (var targetFile = new FileStream(fullPathToDownloadTo, FileMode.CreateNew))
directDownloader.DownloadPackage(dsp.DownloadUrl, dsp, targetFile);
return;
}
var physical = new PhysicalFileSystem(Path.GetDirectoryName(fullPathToDownloadTo));
var local = new LocalPackageRepository(new FixedFilePathResolver(package.Id, fullPathToDownloadTo), physical);
local.AddPackage(package);
}