public async Task <IReadOnlyCollection <MetadataReference> > Install(string packageSearchTerm, IReplLogger logger)
        {
            var nugetLogger = new NugetErrorLogger(logger);

            logger.LogOutput($"Searching for {packageSearchTerm}");
            var package = await FindPackageAsync(packageSearchTerm, repositories, nugetLogger);

            if (package == null)
            {
                logger.LogError($"Could not find package '{packageSearchTerm}'");
                return(Array.Empty <MetadataReference>());
            }
            logger.LogOutput("Found " + Display(package));
            logger.LogOutput("Determining dependences...");

            var dependencies = await GetPackageDependencies(package, nugetFramework, nugetCache, nugetLogger, repositories);

            var packagesToInstall        = ResolvePackages(package, dependencies, nugetLogger);
            var packageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv3,
                XmlDocFileSaveMode.None,
                clientPolicy,
                nugetLogger);

            var assemblyPaths = await Task.WhenAll(packagesToInstall
                                                   .Select(async packageToInstall =>
            {
                var installedPath = packagePathResolver.GetInstalledPath(packageToInstall);
                PackageReaderBase packageReader = installedPath == null
                        ? await DownloadPackage(packageToInstall, packageExtractionContext, nugetLogger)
                        : LocalPackageReader(packageToInstall, installedPath, nugetLogger);

                var allResources = await Task.WhenAll(
                    packageReader.GetLibItemsAsync(CancellationToken.None),
                    packageReader.GetFrameworkItemsAsync(CancellationToken.None)
                    );

                installedPath ??= packagePathResolver.GetInstalledPath(packageToInstall);
                var references = DotNetAssemblyLocator.GroupDirectoryContentsIntoAssemblies(
                    FilterByFramework(frameworkReducer, allResources.SelectMany(x => x).ToList())
                    .Select(item => Path.Combine(installedPath, item))
                    )
                                 .Select(assembly => io.CreateMetadataReferenceWithDocumentation(assembly))
                                 .ToList();

                logger.LogOutput("Installation complete for " + Display(packageToInstall));

                return(references);
            })
                                                   );

            return(assemblyPaths
                   .SelectMany(assemblyGroup => assemblyGroup)
                   .ToList());
        }
 private static PackageFolderReader LocalPackageReader(SourcePackageDependencyInfo packageToInstall, string installedPath, NugetErrorLogger nugetLogger)
 {
     nugetLogger.LogInformationSummary($"Using cached package {Display(packageToInstall)}");
     return(new PackageFolderReader(installedPath));
 }