Esempio n. 1
0
        public static PackageDependencyGroup FindMostCompatibleDependencyGroup(PackageReaderBase package, NuGetFramework target)
        {
            var groups  = package.GetPackageDependencies().ToArray();
            var nearest = new FrameworkReducer().GetNearest(target, groups.Select(x => x.TargetFramework).Where(x => x != null));

            return(nearest != null
                ? groups.Single(x => x.TargetFramework.Equals(nearest))
                : groups.SingleOrDefault(x => x.TargetFramework == null));
        }
Esempio n. 2
0
        public PackageSearchItem(Project project, PackageReaderBase reader)
        {
            Identity = reader.GetIdentity();
            Id       = Identity.Id;
            Title    = reader.NuspecReader.GetTitle();
            if (string.IsNullOrEmpty(Title))
            {
                Title = Id;
            }
            IsInstalled = isPackageIdInProjectDependencies(project, Id);

            InstalledVersion = "";
            // Find installed version !
            var LocalVersion = NuGetPackageManager.Instance.getLocal(Id);

            CanInstall = false;
            if (LocalVersion != null)
            {
                if (project.dependencies != null)
                {
                    foreach (JProperty jp in (JToken)project.dependencies)
                    {
                        if (jp.Name == Id)
                        {
                            InstalledVersion = (string)jp.Value;
                            CanInstall       = true;
                        }
                    }
                }
                if (string.IsNullOrEmpty(InstalledVersion))
                {
                    InstalledVersion = LocalVersion.Identity.Version.ToString();
                }
                SelectedVersion = InstalledVersion;
            }
            NotifyPropertyChanged("InstalledVersion");

            LicenseUrl   = reader.NuspecReader.GetLicenseUrl();
            ProjectUrl   = reader.NuspecReader.GetProjectUrl();
            Tags         = reader.NuspecReader.GetTags();
            Description  = reader.NuspecReader.GetDescription();
            IconUrl      = reader.NuspecReader.GetIconUrl();
            Authors      = reader.NuspecReader.GetAuthors();
            Dependencies = reader.GetPackageDependencies().ToList();
        }