private void UpdateInstalledVersions()
        {
            var hash = new HashSet <NuGetVersion>();

            foreach (var project in _projects)
            {
                try
                {
                    var installedVersion = GetInstalledPackage(project.NuGetProject, Id);
                    if (installedVersion != null)
                    {
                        project.InstalledVersion = installedVersion.PackageIdentity.Version;
                        hash.Add(installedVersion.PackageIdentity.Version);
                        project.AutoReferenced = (installedVersion as BuildIntegratedPackageReference)?.Dependency?.AutoReferenced == true;
                    }
                    else
                    {
                        project.InstalledVersion = null;
                        project.AutoReferenced   = false;
                    }
                }
                catch (Exception ex)
                {
                    project.InstalledVersion = null;

                    // we don't expect it to throw any exception here. But in some edge case when opening manager ui at solution is the
                    // first NuGet operation, and packages.config file is not valid for any of the project, then it will throw here which
                    // should be ignored since we already show a error bar on manager ui to show this exact error.
                    ActivityLog.LogError(NuGetUI.LogEntrySource, ex.ToString());
                }
            }

            InstalledVersionsCount = hash.Count;

            if (hash.Count == 0)
            {
                InstalledVersions = Resources.Text_NotInstalled;
            }
            else if (hash.Count == 1)
            {
                var displayVersion = new DisplayVersion(
                    hash.First(),
                    string.Empty);
                InstalledVersions = displayVersion.ToString();
            }
            else
            {
                InstalledVersions = Resources.Text_MultipleVersionsInstalled;
            }

            UpdateCanInstallAndCanUninstall();
            AutoSelectProjects();
        }
Beispiel #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var version = value as NuGetVersion;

            if (version == null)
            {
                return(null);
            }

            var displayVersion = new DisplayVersion(version, string.Empty, versionFormat: parameter as string);

            return(displayVersion.ToString());
        }
Beispiel #3
0
        private void UpdateInstalledVersions()
        {
            var hash = new HashSet <NuGetVersion>();

            foreach (var project in _projects)
            {
                var installedVersion = GetInstalledPackage(project.NuGetProject, Id);
                if (installedVersion != null)
                {
                    project.InstalledVersion = installedVersion.PackageIdentity.Version;
                    hash.Add(installedVersion.PackageIdentity.Version);
                    project.AutoReferenced = (installedVersion as BuildIntegratedPackageReference)?.Dependency?.AutoReferenced == true;
                }
                else
                {
                    project.InstalledVersion = null;
                }
            }

            InstalledVersionsCount = hash.Count;

            if (hash.Count == 0)
            {
                InstalledVersions = Resources.Text_NotInstalled;
            }
            else if (hash.Count == 1)
            {
                var displayVersion = new DisplayVersion(
                    hash.First(),
                    string.Empty);
                InstalledVersions = displayVersion.ToString();
            }
            else
            {
                InstalledVersions = Resources.Text_MultipleVersionsInstalled;
            }

            UpdateCanInstallAndCanUninstall();
            AutoSelectProjects();
        }