private async Task Download(string sourceName, InternalPackageInformation info, ILocalBaseFolder localBaseFolder, CancellationToken cancelationToken) { listeners(new Resolving(info.Package, info.Source)); var sourceRepository = _sourceRepositories[sourceName]; // This makes it work with coreclr _sourceCacheContext.DirectDownload = true; _sourceCacheContext.RefreshMemoryCache = true; var remoteV3FindPackageByIdResource = await sourceRepository.GetResourceAsync <FindPackageByIdResource>(cancelationToken); await remoteV3FindPackageByIdResource.GetAllVersionsAsync(info.Identity.Id, _sourceCacheContext, NullLogger.Instance, cancelationToken); using (var stream = localBaseFolder.OpenStreamForWriting(PathForNugetPackage(info))) { listeners(new Downloading(info.Package, info.Source)); var result = await remoteV3FindPackageByIdResource.CopyNupkgToStreamAsync(info.Identity.Id, info.Identity.Version, stream, _sourceCacheContext, NullLogger.Instance, cancelationToken ); if (result != true) { throw new InvalidOperationException("Whoa, result is null"); } listeners(new Downloaded(info.Package, info.Source)); } if (info.Package.CleanOnUpdate) { listeners(new Cleaning(info.Package, info.Package.OutputFolder)); localBaseFolder.Clean(info.Package.OutputFolder); } await Decompress(info, localBaseFolder); listeners(new Done(info.Package)); }