public Task ExtractToAsync(string path, CancellationToken cancellationToken) { return(Task.Run( async() => { var content = await EnumerateFiles(cancellationToken); string ExtractFile(string sourceFile, string targetPath, Stream sourceContent) { try { string result = MapPackageFilePath(path, content.frameworkFolderName, targetPath); log.Debug($"Extracting file '{result}'."); using (FileStream targetContent = new FileStream(result, FileMode.OpenOrCreate)) sourceContent.CopyTo(targetContent); return result; } catch (IOException e) { throw new PackageFileExtractionException(targetPath, e); } } await reader.CopyFilesAsync(path, content.packagePaths, ExtractFile, nuGetLog, cancellationToken); }, cancellationToken )); }