Пример #1
0
        public void LoadPackage(IPackage package, IPackageRepository repo, NuGetForm.task task, bool isInstalled)
        {
            if (package == null)
            {
                return;
            }
            this.Dock = DockStyle.Fill;

            if (task == NuGetForm.task.browse)
            {
                SetBrowse(isInstalled);
            }
            if (task == NuGetForm.task.installed)
            {
                SetInstalled(package);
            }
            this.tasks   = task;
            this.package = package;
            pLabel.Text  = package.GetFullName();
            LoadIcon();
            LoadDescription();
            List <IPackage> packages = NuGets.FindPackageById(package.Id, repo);

            cb.Items.Clear();
            foreach (IPackage p in packages)
            {
                cb.Items.Add(p.Version.ToFullString());
            }
        }
Пример #2
0
        private void labelEx3_Click(object sender, EventArgs e)
        {
            EmptyNuGetInfo();
            tasks = task.update;

            UnloadUpdate(tasks);

            if (InstalledPackages == null)
            {
                LoadInstalled();
            }

            NuGets nuget = new NuGets();

            if (repo == null)
            {
                repo = nuget.GetRepository();
            }
            List <IPackage> updates = NuGets.GetUpdates(InstalledPackages, repo);

            dg.Controls.Clear();
            dg.Refresh();

            foreach (IPackage package in updates)
            {
                AddNugetPackageInfo(package, tasks);
            }
        }
Пример #3
0
        private void LoadNextPackages(string text = "Microsoft", bool prerelease = false)
        {
            NuGets nuget = new NuGets();

            if (repo == null)
            {
                repo = nuget.GetRepository();
            }

            this.BeginInvoke(new Action(() =>
            {
                q = NuGets.Select(currentPackage, 10, repo, text, prerelease);

                int i = 0;
                while (i < 10)
                {
                    if (i >= q.Count)
                    {
                        break;
                    }

                    IPackage p = q[i];

                    AddNugetPackageInfo(p);
                    if (i > 10)
                    {
                        break;
                    }
                    i++;
                    currentPackage++;
                }
            }));
        }
Пример #4
0
        private void InstallPackage()
        {
            if (vp == null)
            {
                return;
            }

            string         path = vp.vs.SolutionPath + "\\packages";
            PackageManager p    = NuGets.InstallPackage(package.Id, path, package.Version.ToFullString());

            //string s = p.PathResolver.GetPackageFileName;

            // var c = Directory.GetFiles(path + "\\" + package.AssemblyReferences.ToList()[0].EffectivePath, SearchOption.AllDirectories);

            string file = path + "\\" + package.Id + "." + package.Version.ToFullString() + "\\" + package.AssemblyReferences.ToList()[0].Path;

            vp.SetReference(file);

            foreach (var d in package.DependencySets)
            {
                foreach (var de in d.Dependencies)
                {
                    IPackage package = p.LocalRepository.FindPackage(de.Id);
                    MessageBox.Show("Package " + package.GetFullName() + "found");

                    file = path + "\\" + package.Id + "." + package.Version.ToFullString() + "\\" + package.AssemblyReferences.ToList()[0].Path;

                    vp.SetReference(file);
                }
            }
        }
Пример #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Ready to uninstall");

            string path = vp.vs.SolutionPath + "\\packages";

            PackageManager p = NuGets.UninstallPackage(package.Id, path, package.Version.ToFullString(), false);

            //string s = p.PathResolver.GetPackageFileName;

            // var c = Directory.GetFiles(path + "\\" + package.AssemblyReferences.ToList()[0].EffectivePath, SearchOption.AllDirectories);

            string file = path + "\\" + package.Id + "." + package.Version.ToFullString() + "\\" + package.AssemblyReferences.ToList()[0].Path;

            vp.RemoveReference(file);

            //foreach (var d in package.DependencySets)
            //{
            //    foreach (var de in d.Dependencies)
            //    {
            //        IPackage package = p.LocalRepository.FindPackage(de.Id);
            //        MessageBox.Show("Package " + package.GetFullName() + "found");

            //        file = path + "\\" + package.Id + "." + package.Version.ToFullString() + "\\" + package.AssemblyReferences.ToList()[0].Path;

            //        vp.RemoveReference(file);
            //    }
            //}
        }
Пример #6
0
        public void AddNugetPackageInfo(IPackage package, task tasks = task.none)
        {
            NuGetPacketShort s = new NuGetPacketShort(tasks);
            //s.Width = this.sp.Panel1.Width - 5;
            string text = "";

            foreach (string b in package.Authors)
            {
                text += " " + b;
            }

            s.SetMainText("" + package.GetFullName() + "  by " + text + "\n" + package.Description);
            s.SetAsBold(package.GetFullName());
            if (package.IconUrl != null)
            {
                try
                {
                    Bitmap icon = NuGets.GetIcon(package.IconUrl);//NuGets.NuGetUrl(package.IconUrl);
                    if (icon == null || icon.Width == 0)
                    {
                        icon = ve_resource.VSO_NugetLogo_52x;
                    }
                    s.SetIcon(icon);
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                Bitmap icon = ve_resource.VSO_NugetLogo_52x;
                s.SetIcon(icon);
            }
            if (package.Version != null)
            {
                s.SetVersion(package.Version.ToFullString());
            }
            else
            {
                s.SetVersion("");
            }
            s.nugetShortSelectedEvent += S_nugetShortSelectedEvent;

            s.SetPackage(package);
            s.AutoScroll = false;
            dg.AddControl(s);
            //dg.Refresh();
        }
Пример #7
0
 public void LoadIcon()
 {
     if (package.IconUrl != null)
     {
         try
         {
             Bitmap icon = NuGets.NuGetUrl(package.IconUrl);
             if (icon != null)
             {
                 pbIcon.Image = icon;
             }
         }
         catch (Exception ex)
         {
         }
     }
 }
Пример #8
0
        private void UpdatePackage()
        {
            if (vp == null)
            {
                return;
            }

            string path = vp.vs.SolutionPath + "\\packages";

            string version = cbUpdate.Text;

            if (string.IsNullOrEmpty(version))
            {
                return;
            }

            //Connect to the official package repository
            IPackageRepository repo  = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
            PackageManager     pp    = new PackageManager(repo, path);
            string             files = path + "\\" + package.Id + "." + package.Version.ToFullString() + "\\" + package.AssemblyReferences.ToList()[0].Path;

            vp.RemoveReference(files);

            PackageManager p    = NuGets.UpdatePackage(package.Id, path, version, false);
            string         file = path + "\\" + package.Id + "." + version + "\\" + package.AssemblyReferences.ToList()[0].Path;

            vp.SetReference(file);

            //foreach (var d in package.DependencySets)
            //{
            //    foreach (var de in d.Dependencies)
            //    {
            //        IPackage package = p.LocalRepository.FindPackage(de.Id);
            //        MessageBox.Show("Package " + package.GetFullName() + "found");

            //        file = path + "\\" + package.Id + "." + package.Version.ToFullString() + "\\" + package.AssemblyReferences.ToList()[0].Path;

            //        vp.SetReference(file);
            //    }
            //}
        }
Пример #9
0
        private void labelEx1_Click(object sender, EventArgs e)
        {
            EmptyNuGetInfo();
            NuGets nuget = new NuGets();

            tasks = task.browse;
            if (repo == null)
            {
                repo = nuget.GetRepository();
            }
            //IQueryable<IPackage> q = nuget.repo.GetPackages();
            currentPackage = 0;

            UnloadUpdate(tasks);

            dg.ClearControls();
            dg.Refresh();

            this.BeginInvoke(new Action(() =>
            {
                q     = NuGets.Select(currentPackage, 10, repo);
                int i = 0;
                while (i < 10)
                {
                    if (i >= q.Count)
                    {
                        break;
                    }
                    IPackage p = q[i];
                    AddNugetPackageInfo(p);
                    if (i > 10)
                    {
                        break;
                    }
                    i++;
                    currentPackage++;
                }
            }));
        }
Пример #10
0
        private void LoadInstalled(bool loadInfo = false)
        {
            InstalledPackages = new List <IPackage>();
            if (vs == null)
            {
                return;
            }

            dg.Controls.Clear();
            dg.Refresh();
            ArrayList L = vs.GetReferences();

            foreach (string p in L)
            {
                string hint = vs.GetPathHint(p);
                if (String.IsNullOrEmpty(hint))
                {
                    continue;
                }
                string folder = vs.vs.SolutionPath + hint;

                if (File.Exists(folder))
                {
                }

                string pp = "";

                string bg = vs.GetProjectFolder() + "\\" + hint;

                string[] cc = bg.Split("\\".ToCharArray());

                List <string> bb = new List <string>(cc);

                int i = bb.IndexOf("packages");

                int j = 0;
                foreach (string s in bb)
                {
                    if (j != 0)
                    {
                        pp += "\\" + s;
                    }
                    else
                    {
                        pp = s;
                    }

                    if (j > i)
                    {
                        break;
                    }
                    j++;
                }

                if (!Directory.Exists(pp))
                {
                    continue;
                }

                string[] dd = Directory.GetFiles(pp);

                IPackage package = null;

                foreach (string d in dd)
                {
                    if (d.EndsWith(".nupkg"))
                    {
                        package = NuGets.ReadNuSpec(d);

                        break;
                    }
                }

                if (package == null)
                {
                    continue;
                }

                InstalledPackages.Add(package);
                if (loadInfo == true)
                {
                    IPackage packages = NuGets.GetNuGetPackage(package.Id, package.Version.ToFullString());
                    if (packages != null)
                    {
                        AddNugetPackageInfo(packages);
                    }
                }
            }
        }
Пример #11
0
        private void labelEx2_Click(object sender, EventArgs e)
        {
            EmptyNuGetInfo();
            InstalledPackages = new List <IPackage>();
            if (repo == null)
            {
                NuGets nuget = new NuGets();
                repo = nuget.GetRepository();
            }
            if (vs == null)
            {
                return;
            }
            tasks = task.installed;
            UnloadUpdate(tasks);

            dg.Controls.Clear();
            dg.Refresh();
            ArrayList L = vs.GetReferences();

            foreach (string p in L)
            {
                string hint = vs.GetPathHint(p);
                if (String.IsNullOrEmpty(hint))
                {
                    continue;
                }
                string folder = vs.vs.SolutionPath + hint;

                if (File.Exists(folder))
                {
                }

                string pp = "";

                string bg = vs.GetProjectFolder() + "\\" + hint;

                string[] cc = bg.Split("\\".ToCharArray());

                List <string> bb = new List <string>(cc);

                int i = bb.IndexOf("packages");

                int j = 0;
                foreach (string s in bb)
                {
                    if (j != 0)
                    {
                        pp += "\\" + s;
                    }
                    else
                    {
                        pp = s;
                    }

                    if (j > i)
                    {
                        break;
                    }
                    j++;
                }

                pp = Path.GetFullPath(pp);

                if (!Directory.Exists(pp))
                {
                    continue;
                }

                string[] dd = Directory.GetFiles(pp);

                IPackage package = null;

                foreach (string d in dd)
                {
                    if (d.EndsWith(".nupkg"))
                    {
                        package = NuGets.ReadNuSpec(d);

                        break;
                    }
                }

                if (package == null)
                {
                    continue;
                }

                InstalledPackages.Add(package);

                {
                    IPackage packages = NuGets.GetNuGetPackage(package.Id, package.Version.ToFullString());
                    if (packages != null)
                    {
                        AddNugetPackageInfo(packages);
                    }
                }
            }
        }