public async Task Initialize() { var nuGetDownloader = new NuGetDownloader(_options.LoggerFactory()); var packages = await nuGetDownloader.SearchPackagesAsync(_packageFeed, _searchTerm, maxResults : _maxPackages); foreach (var packageAndRepo in packages) { var packageCatalog = new NugetPackagePluginCatalog(packageAndRepo.Package.Identity.Id, packageAndRepo.Package.Identity.Version.ToString(), _includePrereleases, _packageFeed, PackagesFolder, criterias: _typeFinderCriterias); await packageCatalog.Initialize(); _pluginCatalogs.Add(packageCatalog); } IsInitialized = true; }
private async Task <(SourceRepository Repository, IPackageSearchMetadata Package)> FindPackage() { (SourceRepository Repository, IPackageSearchMetadata Package)result = default; var foundPackages = new List <(SourceRepository Repository, IPackageSearchMetadata Package)>(); if (!string.IsNullOrWhiteSpace(Configuration.PackageFeedUrl)) { var feed = new NuGetFeed(Configuration.Package, Configuration.PackageFeedUrl) { Username = Configuration.PackageFeedUsername, Password = Configuration.PackageFeedPassword }; var packages = await _nuGetDownloader.SearchPackagesAsync(feed, _packageName, 20, includePrerelease : true); foreach (var foundPackage in packages) { foundPackages.Add(foundPackage); if (string.Equals(foundPackage.Package.Identity.Id, _packageName, StringComparison.InvariantCultureIgnoreCase)) { result = foundPackage; break; } } } else { await foreach (var foundPackage in _nuGetDownloader.SearchPackagesAsync(_packageName, includePrerelease: true, nugetConfigFilePath: _nugetConfigPath)) { foundPackages.Add(foundPackage); if (string.Equals(foundPackage.Package.Identity.Id, _packageName, StringComparison.InvariantCultureIgnoreCase)) { result = foundPackage; break; } } } if (result != default) { return(result); } _logger.Error("Couldn't find package using the exact id {PackageName}", _packageName); if (foundPackages.Any() == true) { _logger.Error("Found the following non-matching packages:"); foreach (var nonMatchingPackage in foundPackages) { _logger.Error($"{nonMatchingPackage.Package.Identity}"); } } throw new Exception("Couldn't find the package with the identifier " + _packageName); }