public void GetInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, BootstrapRequest request) { if (request == null) { throw new ArgumentNullException("request"); } request.Debug("Calling '{0}::GetInstalledPackages' '{1}','{2}','{3}','{4}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion); //search under the providerAssembies folder for the installed providers var providers = PackageManagementService.AllProvidersFromProviderAssembliesLocation(request).Select(providerFileAssembly => { //get the provider's name\version var versionFolder = Path.GetDirectoryName(providerFileAssembly); if (string.IsNullOrWhiteSpace(versionFolder)) { return(null); } Version ver; if (!Version.TryParse(Path.GetFileName(versionFolder), out ver)) { //this will cover whether the providerFileAssembly is at top level as well as a bad version folder //skip if the provider is at the top level as they are imported already via LoadProviders() during the initialization. //the provider will be handled PackageManagementService.DynamicProviders below. return(null); } var providerNameFolder = Path.GetDirectoryName(versionFolder); if (!string.IsNullOrWhiteSpace(providerNameFolder)) { var providerName = Path.GetFileName(providerNameFolder); if (!string.IsNullOrWhiteSpace(providerName)) { return(new { Name = providerName, Version = (FourPartVersion)ver, ProviderPath = providerFileAssembly }); } } return(null); }).WhereNotNull(); // return all the dynamic package providers as packages providers = providers.Concat(PackageManagementService.DynamicProviders.Select(each => new { Name = each.ProviderName, each.Version, each.ProviderPath })).Distinct(); var pp = request.LocalSource.Any() ? providers.Select(each => request.GetProviderFromFile(each.ProviderPath, false, true)).WhereNotNull() : providers.Select(each => request.GetProvider(each.Name, each.Version)).WhereNotNull(); foreach (var p in pp) { request.YieldFromSwidtag(p, requiredVersion, minimumVersion, maximumVersion, name); } }
public void GetInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, BootstrapRequest request) { if (request == null) { throw new ArgumentNullException("request"); } request.Debug("Calling '{0}::GetInstalledPackages' '{1}','{2}','{3}','{4}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion); //search under the providerAssembies folder for the installed providers var providers = PackageManagementService.AllProvidersFromProviderAssembliesLocation(request).Select(providerFileAssembly => { //get the provider's name\version var versionFolder = Path.GetDirectoryName(providerFileAssembly); if (string.IsNullOrWhiteSpace(versionFolder)) { return(null); } Version ver; if (!Version.TryParse(Path.GetFileName(versionFolder), out ver)) { //this will cover whether the providerFileAssembly is at top level as well as a bad version folder //skip if the provider is at the top level as they are imported already via LoadProviders() during the initialization. //the provider will be handled PackageManagementService.DynamicProviders below. return(null); } var providerNameFolder = Path.GetDirectoryName(versionFolder); if (!string.IsNullOrWhiteSpace(providerNameFolder)) { var providerName = Path.GetFileName(providerNameFolder); if (!string.IsNullOrWhiteSpace(providerName)) { return(new { Name = providerName, Version = (FourPartVersion)ver, ProviderPath = providerFileAssembly }); } } return(null); }).WhereNotNull(); // return all the dynamic package providers as packages providers = providers.Concat(PackageManagementService.DynamicProviders.Select(each => new { Name = each.ProviderName, each.Version, each.ProviderPath })).Distinct(); foreach (var provider in providers) { // for each package manager, match it's name and version with the swidtag from the remote feed var p = request.GetProvider(provider.Name, provider.Version); if (p == null) { request.Debug("Dynamic provider '{0}' from '{1}' is not listed in a bootstrap feed.", provider.Name, provider.ProviderPath); // we didn't find it. It's possible that the provider is listed elsewhere. // well, we'll return as much info as we have. continue; } request.YieldFromSwidtag(p, requiredVersion, minimumVersion, maximumVersion, name); } }