Пример #1
0
        private void GetDependenciesRecursive(List <IPackageRepository> repositories, PackageDependency dependency, CpuArchitecture packageArchitecture, string OS)
        {
            if (Dependencies.Any(p => (p.Name == dependency.Name) &&
                                 dependency.Version.IsCompatible(p.Version) &&
                                 ArchitectureHelper.PluginsCompatible(p.Architecture, packageArchitecture)))
            {
                return;
            }
            PackageDef depPkg = GetPackageDefFromInstallation(dependency.Name, dependency.Version);

            if (depPkg == null)
            {
                depPkg = GetPackageDefFromRepo(repositories, dependency.Name, dependency.Version);
                MissingDependencies.Add(depPkg);
            }
            if (depPkg == null)
            {
                UnknownDependencies.Add(dependency);
                return;
            }
            Dependencies.Add(depPkg);
            foreach (var nextLevelDep in depPkg.Dependencies)
            {
                GetDependenciesRecursive(repositories, nextLevelDep, packageArchitecture, OS);
            }
        }
Пример #2
0
        private PackageDef GetPackageDefFromRepo(List <IPackageRepository> repositories, string name, VersionSpecifier version)
        {
            if (name.ToLower().EndsWith(".tappackage"))
            {
                name = Path.GetFileNameWithoutExtension(name);
            }

            var specifier = new PackageSpecifier(name, version, CpuArchitecture.Unspecified, OperatingSystem.Current.ToString());
            var packages  = PackageRepositoryHelpers.GetPackagesFromAllRepos(repositories, specifier, InstalledPackages.Values.ToArray());

            if (packages.Any() == false)
            {
                packages = PackageRepositoryHelpers.GetPackagesFromAllRepos(repositories, specifier);
                if (packages.Any())
                {
                    log.Warning($"Unable to find a version of '{name}' package compatible with currently installed packages. Some installed packages may be upgraded.");
                }
            }

            return(packages.OrderByDescending(pkg => pkg.Version).FirstOrDefault(pkg => ArchitectureHelper.PluginsCompatible(pkg.Architecture, ArchitectureHelper.HostArchitecture)));
        }