Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        internal void InstallPackage(string fastPath, BootstrapRequest request, bool errorContinue)
        {
            if (fastPath == null)
            {
                throw new ArgumentNullException("fastPath");
            }
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            // ensure that mandatory parameters are present.
            request.Debug("Calling 'Bootstrap::InstallPackage'");
            var triedAndFailed = false;

            //source can be from install - packageprovider or can be from the pipeline
            if ((request.LocalSource.Any() || fastPath.IsFile()))
            {
                InstallPackageFromFile(fastPath, request);
                return;
            }

            // verify the package integrity (ie, check if it's digitally signed before installing)

            var provider = request.GetProvider(new Uri(fastPath));

            if (provider == null || !provider.IsValid)
            {
                var result = errorContinue ? request.Warning(Constants.Messages.UnableToResolvePackage, fastPath) : request.Error(ErrorCategory.InvalidData, fastPath, Constants.Messages.UnableToResolvePackage, fastPath);
                return;
            }

            // first install the dependencies if any
            var dependencyLinks = provider._swidtag.Links.Where(link => link.Relationship == Iso19770_2.Relationship.Requires).GroupBy(link => link.Artifact);

            foreach (var depLinks in dependencyLinks)
            {
                foreach (var item in depLinks)
                {
                    Package packages = null;
                    if (string.IsNullOrWhiteSpace(item.Attributes[Iso19770_2.Discovery.Name]))
                    {
                        //select the packages that marked as "latest"
                        packages = (new Feed(request, new[] { item.HRef })).Query().FirstOrDefault();
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(item.Attributes[Iso19770_2.Discovery.Version]))
                        {
                            //select the packages that marked as "latest" and matches the name specified
                            packages = (new Feed(request, new[] { item.HRef })).Query().FirstOrDefault(p => p.Name.EqualsIgnoreCase(item.Attributes[Iso19770_2.Discovery.Name]));
                        }
                        else
                        {
                            //select the packages that matches version and name
                            packages = (new Feed(request, new[] { item.HRef })).Query(item.Attributes[Iso19770_2.Discovery.Name], item.Attributes[Iso19770_2.Discovery.Version]).FirstOrDefault();
                        }
                    }

                    if (packages == null)
                    {
                        // no package found
                        request.Warning(Resources.Messages.NoDependencyPackageFound, item.HRef);
                        continue;
                    }
                    // try to install dependent providers. If fails, continue
                    InstallPackage(packages.Location.AbsoluteUri, request, errorContinue: true);
                }
            }

            // group the links along 'artifact' lines
            var artifacts = provider._swidtag.Links.Where(link => link.Relationship == Iso19770_2.Relationship.InstallationMedia).GroupBy(link => link.Artifact);


            // try one artifact set at a time.
            foreach (var artifact in artifacts)
            {
                // first time we succeed, we're good to go.
                foreach (var link in artifact)
                {
                    switch (link.Attributes[Iso19770_2.Discovery.Type])
                    {
                    case "assembly":
                        if (InstallAssemblyProvider(provider, link, fastPath, request))
                        {
                            return;
                        }
                        triedAndFailed = true;
                        continue;

                    default:
                        if (InstallProviderFromInstaller(provider, link, fastPath, request))
                        {
                            return;
                        }
                        triedAndFailed = true;
                        continue;
                    }
                }
            }

            if (triedAndFailed)
            {
                // we tried installing something and it didn't go well.
                var result = errorContinue ? request.Warning(Constants.Messages.FailedProviderBootstrap, fastPath) : request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.FailedProviderBootstrap, fastPath);
            }
            else
            {
                // we didn't even find a link to bootstrap.
                var result = errorContinue ? request.Warning(Resources.Messages.MissingInstallationmedia, fastPath) : request.Error(ErrorCategory.InvalidOperation, fastPath, Resources.Messages.MissingInstallationmedia, fastPath);
            }
        }
Ejemplo n.º 3
0
        public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, BootstrapRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            request.Verbose(Resources.Messages.FindingPackage, string.Format(CultureInfo.CurrentCulture, "{0}::FindPackage' '{1}','{2}','{3}','{4}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion));

            if (name != null && name.EqualsIgnoreCase("PackageManagement"))
            {
                // they are looking for PackageManagement itself.
                // future todo: let PackageManagement update itself.
                return;
            }

            if (request.LocalSource.Any())
            {
                // find a provider from given path
                request.FindProviderFromFile(name, requiredVersion, minimumVersion, maximumVersion);
                return;
            }

            // are they are looking for a specific provider?
            if (string.IsNullOrWhiteSpace(name) || WildcardPattern.ContainsWildcardCharacters(name))
            {
                // no, return all providers that match the range.
                var wildcardPattern = new WildcardPattern(name, WildcardOptions);

                if (request.GetOptionValue("AllVersions").IsTrue())
                {
                    // Feed.Query() can return an empty provider, so here we need to execlude it by checking p.Name !=null or empty.
                    foreach (var p in request.Providers.Distinct(PackageEqualityComparer).Where(p => !string.IsNullOrWhiteSpace(p.Name) && (string.IsNullOrWhiteSpace(name) || wildcardPattern.IsMatch(p.Name))))
                    {
                        FindPackage(p.Name, null, "0.0", null, 0, request);
                    }
                    return;
                }

                if (request.Providers.Distinct(PackageEqualityComparer).Where(p => string.IsNullOrWhiteSpace(name) || wildcardPattern.IsMatch(p.Name)).Any(p => !request.YieldFromSwidtag(p, requiredVersion, minimumVersion, maximumVersion, name)))
                {
                    // if there is a problem, exit.
                    return;
                }
            }
            else
            {
                // return just the one they asked for.

                // asked for a specific version?
                if (!string.IsNullOrWhiteSpace(requiredVersion))
                {
                    request.YieldFromSwidtag(request.GetProvider(name, requiredVersion), name);
                    return;
                }

                if (request.GetOptionValue("AllVersions").IsTrue())
                {
                    if (request.GetProviderAll(name, minimumVersion, maximumVersion).Distinct(PackageEqualityComparer).Any(provider => !request.YieldFromSwidtag(provider, name)))
                    {
                        // if there is a problem, exit.
                        return;
                    }
                    return;
                }

                // asked for a version range?
                if (!string.IsNullOrWhiteSpace(minimumVersion) || !string.IsNullOrEmpty(maximumVersion))
                {
                    if (request.GetProvider(name, minimumVersion, maximumVersion).Distinct(PackageEqualityComparer).Any(provider => !request.YieldFromSwidtag(provider, name)))
                    {
                        // if there is a problem, exit.
                        return;
                    }
                    return;
                }

                // just return by name
                request.YieldFromSwidtag(request.GetProvider(name), name);
            }

            // return any matches in the name
        }
Ejemplo n.º 4
0
        public void InstallPackage(string fastPath, BootstrapRequest request)
        {
            if (request == null) {
                throw new ArgumentNullException("request");
            }
            // ensure that mandatory parameters are present.
            request.Debug("Calling 'Bootstrap::InstallPackage'");
            var triedAndFailed = false;

            // verify the package integrity (ie, check if it's digitally signed before installing)

            var provider = request.GetProvider(new Uri(fastPath));
            if (provider == null || !provider.IsValid) {
                request.Error(ErrorCategory.InvalidData, fastPath, Constants.Messages.UnableToResolvePackage, fastPath);
                return;
            }

            // group the links along 'artifact' lines
            var artifacts = provider._swidtag.Links.Where(link => link.Relationship == Iso19770_2.Relationship.InstallationMedia).GroupBy(link => link.Artifact);

            // try one artifact set at a time.
            foreach (var artifact in artifacts) {
                // first time we succeed, we're good to go.
                foreach (var link in artifact) {
                    switch (link.Attributes[Iso19770_2.Discovery.Type]) {
                        case "assembly":
                            if (InstallAssemblyProvider(provider, link, fastPath, request)) {
                                return;
                            }
                            triedAndFailed = true;
                            continue;

                        default:
                            if (InstallProviderFromInstaller(provider, link, fastPath, request)) {
                                return;
                            }
                            triedAndFailed = true;
                            continue;
                    }
                }
            }

            if (triedAndFailed) {
                // we tried installing something and it didn't go well.
                request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.FailedProviderBootstrap, fastPath);
            } else {
                // we didn't even find a link to bootstrap.
                request.Error(ErrorCategory.InvalidOperation, fastPath, "Provider {0} missing installationmedia to install.", fastPath);
            }
        }
Ejemplo n.º 5
0
        public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, BootstrapRequest request)
        {
            if (request == null) {
                throw new ArgumentNullException("request");
            }

            request.Verbose(Resources.Messages.FindingPackage, string.Format(CultureInfo.CurrentCulture, "{0}::FindPackage' '{1}','{2}','{3}','{4}'", PackageProviderName, name, requiredVersion, minimumVersion, maximumVersion));

            if (name != null && name.EqualsIgnoreCase("PackageManagement")) {
                // they are looking for PackageManagement itself.
                // future todo: let PackageManagement update itself.
                return;
            }

            // are they are looking for a specific provider?
            if (string.IsNullOrWhiteSpace(name) || WildcardPattern.ContainsWildcardCharacters(name)) {

                // no, return all providers that match the range.
                var wildcardPattern = new WildcardPattern(name, WildcardOptions);

                if (request.GetOptionValue("AllVersions").IsTrue()) {
                    foreach (var p in request.Providers.Distinct(PackageEqualityComparer).Where(p => string.IsNullOrWhiteSpace(name) || wildcardPattern.IsMatch(p.Name))) {
                        FindPackage(p.Name, null, "0.0", null, 0, request);
                    }
                    return;
                }

                if (request.Providers.Distinct(PackageEqualityComparer).Where(p => string.IsNullOrWhiteSpace(name) || wildcardPattern.IsMatch(p.Name)).Any(p => !request.YieldFromSwidtag(p, requiredVersion, minimumVersion, maximumVersion, name))) {
                    // if there is a problem, exit.
                    return;
                }
            } else {
                // return just the one they asked for.

                // asked for a specific version?
                if (!string.IsNullOrWhiteSpace(requiredVersion)) {
                    request.YieldFromSwidtag(request.GetProvider(name, requiredVersion), name);
                    return;
                }

                if (request.GetOptionValue("AllVersions").IsTrue()) {
                    if (request.GetProviderAll(name, minimumVersion, maximumVersion).Distinct(PackageEqualityComparer).Any(provider => !request.YieldFromSwidtag(provider, name))) {
                        // if there is a problem, exit.
                        return;
                    }
                    return;
                }

                // asked for a version range?
                if (!string.IsNullOrWhiteSpace(minimumVersion) || !string.IsNullOrEmpty(maximumVersion)) {
                    if (request.GetProvider(name, minimumVersion, maximumVersion).Distinct(PackageEqualityComparer).Any(provider => !request.YieldFromSwidtag(provider, name))) {
                        // if there is a problem, exit.
                        return;
                    }
                    return;
                }

                // just return by name
                request.YieldFromSwidtag(request.GetProvider(name), name);
            }

            // return any matches in the name
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        internal void InstallPackage(string fastPath, BootstrapRequest request, bool errorContinue) {
            if (fastPath == null) {
                throw new ArgumentNullException("fastPath");
            }
            if (request == null) {
                throw new ArgumentNullException("request");
            }
            // ensure that mandatory parameters are present.
            request.Debug("Calling 'Bootstrap::InstallPackage'");
            var triedAndFailed = false;

            //source can be from install - packageprovider or can be from the pipeline
            if ((request.LocalSource.Any() || fastPath.IsFile()))
            {
                InstallPackageFromFile(fastPath, request);
                return;
            }

            // verify the package integrity (ie, check if it's digitally signed before installing)

            var provider = request.GetProvider(new Uri(fastPath));
            if (provider == null || !provider.IsValid) {
                var result = errorContinue ? request.Warning(Constants.Messages.UnableToResolvePackage, fastPath) : request.Error(ErrorCategory.InvalidData, fastPath, Constants.Messages.UnableToResolvePackage, fastPath);
                return;
            }

            // first install the dependencies if any
            var dependencyLinks = provider._swidtag.Links.Where(link => link.Relationship == Iso19770_2.Relationship.Requires).GroupBy(link => link.Artifact);
            foreach (var depLinks in dependencyLinks) {
                foreach (var item in depLinks) {
                    Package packages = null;
                    if (string.IsNullOrWhiteSpace(item.Attributes[Iso19770_2.Discovery.Name])) {
                        //select the packages that marked as "latest"
                        packages = (new Feed(request, new[] {item.HRef})).Query().FirstOrDefault();
                    } else {
                        if (string.IsNullOrWhiteSpace(item.Attributes[Iso19770_2.Discovery.Version])) {
                            //select the packages that marked as "latest" and matches the name specified
                            packages = (new Feed(request, new[] { item.HRef })).Query().FirstOrDefault(p => p.Name.EqualsIgnoreCase(item.Attributes[Iso19770_2.Discovery.Name]));
                        } else {
                            //select the packages that matches version and name
                            packages = (new Feed(request, new[] { item.HRef })).Query(item.Attributes[Iso19770_2.Discovery.Name], item.Attributes[Iso19770_2.Discovery.Version]).FirstOrDefault();
                        }
                    }

                    if (packages == null) {
                        // no package found
                        request.Warning(Resources.Messages.NoDependencyPackageFound, item.HRef);
                        continue;
                    }
                    // try to install dependent providers. If fails, continue
                    InstallPackage(packages.Location.AbsoluteUri, request, errorContinue: true);
                }
            }

            // group the links along 'artifact' lines
            var artifacts = provider._swidtag.Links.Where(link => link.Relationship == Iso19770_2.Relationship.InstallationMedia).GroupBy(link => link.Artifact);


            // try one artifact set at a time.
            foreach (var artifact in artifacts) {
                // first time we succeed, we're good to go.
                foreach (var link in artifact) {
                    switch (link.Attributes[Iso19770_2.Discovery.Type]) {
                        case "assembly":
                            if (InstallAssemblyProvider(provider, link, fastPath, request)) {
                                return;
                            }
                            triedAndFailed = true;
                            continue;

                        default:
                            if (InstallProviderFromInstaller(provider, link, fastPath, request)) {
                                return;
                            }
                            triedAndFailed = true;
                            continue;
                    }
                }
            }

            if (triedAndFailed) {
                // we tried installing something and it didn't go well.
                var result = errorContinue ? request.Warning(Constants.Messages.FailedProviderBootstrap, fastPath) : request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.FailedProviderBootstrap, fastPath);
            } else {
                // we didn't even find a link to bootstrap.
                var result = errorContinue ? request.Warning(Resources.Messages.MissingInstallationmedia, fastPath) : request.Error(ErrorCategory.InvalidOperation, fastPath, Resources.Messages.MissingInstallationmedia, fastPath);
            }
        }
Ejemplo n.º 8
0
        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 providerAssemblies 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);
            }
        }
Ejemplo n.º 9
0
        public void InstallPackage(string fastPath, BootstrapRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            // ensure that mandatory parameters are present.
            request.Debug("Calling 'Bootstrap::InstallPackage'");
            var triedAndFailed = false;

            // verify the package integrity (ie, check if it's digitally signed before installing)

            var provider = request.GetProvider(new Uri(fastPath));

            if (provider == null || !provider.IsValid)
            {
                request.Error(ErrorCategory.InvalidData, fastPath, Constants.Messages.UnableToResolvePackage, fastPath);
                return;
            }

            // group the links along 'artifact' lines
            var artifacts = provider._swidtag.Links.Where(link => link.Relationship == Iso19770_2.Relationship.InstallationMedia).GroupBy(link => link.Artifact);

            // try one artifact set at a time.
            foreach (var artifact in artifacts)
            {
                // first time we succeed, we're good to go.
                foreach (var link in artifact)
                {
                    switch (link.Attributes[Iso19770_2.Discovery.Type])
                    {
                    case "assembly":
                        if (InstallAssemblyProvider(provider, link, fastPath, request))
                        {
                            return;
                        }
                        triedAndFailed = true;
                        continue;

                    default:
                        if (InstallProviderFromInstaller(provider, link, fastPath, request))
                        {
                            return;
                        }
                        triedAndFailed = true;
                        continue;
                    }
                }
            }

            if (triedAndFailed)
            {
                // we tried installing something and it didn't go well.
                request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.FailedProviderBootstrap, fastPath);
            }
            else
            {
                // we didn't even find a link to bootstrap.
                request.Error(ErrorCategory.InvalidOperation, fastPath, "Provider {0} missing installationmedia to install.", fastPath);
            }
        }
Ejemplo n.º 10
0
        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);
            }
        }