Exemplo n.º 1
0
        private void RunCommand(string helpTopic,
                                Action <SolutionInfo> command,
                                TaskScheduler taskScheduler = null)
        {
            PaketOutputPane.OutputPane.Activate();
            taskScheduler = taskScheduler ?? TaskScheduler.Default;
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");
            var info = new SolutionInfo();

            info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
            info.FileName  = SolutionExplorerExtensions.GetSolutionDirectory();
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, tracker.GetSelectedFileName(), helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }, CancellationToken.None, TaskCreationOptions.None, taskScheduler);
            System.Threading.Tasks.Task.Run(() =>
            {
            });
        }
Exemplo n.º 2
0
        private void AddPackageToProject(object sender, EventArgs e)
        {
            var helpTopic = "paket-add.html#Adding-to-a-single-project";

            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();

            var projectFileName = tracker.GetSelectedFileName();

            StatusBarService.UpdateText("Add NuGet package to " + projectFileName);

            var projectGuid = tracker.GetSelectedProjectGuid();

            SolutionExplorerExtensions.SaveSolution();

            try
            {
                AddPackageProcess.ShowAddPackageDialog(projectFileName, projectGuid.ToString());

                PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                StatusBarService.UpdateText("Ready");
            }
            catch (Exception ex)
            {
                SolutionExplorerExtensions.ReloadProject(projectGuid);
                PaketErrorPane.ShowError(ex.Message, projectFileName, helpTopic);
                PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
            }
        }
Exemplo n.º 3
0
 public void Restore(IEnumerable <RestoringProject> projects)
 {
     try
     {
         restorer.Restore(projects);
     }
     catch (Exception ex)
     {
         PaketErrorPane.ShowError(ex.Message, "Paket restore error !", "paket-restore.html");
         PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
     }
 }
Exemplo n.º 4
0
        private void RunCommandOnPackageAndReloadAllDependendProjects(string helpTopic, Action <PackageInfo> command)
        {
            var node = tracker.SelectedGraphNode;

            if (node == null || !node.HasCategory(PaketGraphSchema.PaketCategory))
            {
                return;
            }

            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");

            var info = new PackageInfo();

            info.DependenciesFileName = node.Id.GetFileName();
            info.PackageName          = node.GetPackageName();
            info.GroupName            = node.GetGroupName();

            var projectGuids =
                Dependencies.Locate(info.DependenciesFileName)
                .FindProjectsFor(info.GroupName, info.PackageName)
                .Select(project => project.GetProjectGuid())
                .ToArray();

            SolutionExplorerExtensions.SaveSolution();
            foreach (var projectGuid in projectGuids)
            {
                SolutionExplorerExtensions.UnloadProject(projectGuid);
            }

            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, info.DependenciesFileName, helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }).ContinueWith(_ =>
            {
                foreach (var projectGuid in projectGuids)
                {
                    SolutionExplorerExtensions.ReloadProject(projectGuid);
                }
            });
        }
Exemplo n.º 5
0
        public void Restore(Dependencies dependencies, IEnumerable <RestoringProject> projects)
        {
            PaketErrorPane.Clear();
            PaketOutputPane.OutputPane.OutputStringThreadSafe("Restoring packages\r\n");

            try
            {
                restorer.Restore(dependencies, projects);
            }
            finally
            {
                PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
            }
        }
 public void Restore(Dependencies dependencies, IEnumerable <RestoringProject> projects)
 {
     foreach (var project in projects)
     {
         try
         {
             restorer.Restore(dependencies, new[] { project });
         }
         catch (Exception ex)
         {
             PaketErrorPane.ShowError(ex.Message, project.ReferenceFile, "paket-restore.html");
             PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
         }
     }
 }
Exemplo n.º 7
0
        private void RunCommandAndReloadAllProjects(string helpTopic, Action <SolutionInfo> command)
        {
            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");

            var info = new SolutionInfo();

            info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
            info.FileName  = SolutionExplorerExtensions.GetSolutionDirectory();
            var projectGuids = SolutionExplorerExtensions.GetAllProjectGuids();

            SolutionExplorerExtensions.SaveSolution();

            // https://github.com/fsprojects/Paket.VisualStudio/issues/84
            // explicitly save unsaved projects
            foreach (var project in SolutionExplorerExtensions.GetAllProjects().Where(p => false == p.Saved))
            {
                project.Save();
            }

            foreach (var projectGuid in projectGuids)
            {
                SolutionExplorerExtensions.UnloadProject(projectGuid);
            }

            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, info.FileName, helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }).ContinueWith(_ =>
            {
                foreach (var projectGuid in projectGuids)
                {
                    SolutionExplorerExtensions.ReloadProject(projectGuid);
                }
            });
        }
        private void RunCommandAndReloadAllProjects(string helpTopic, Action <SolutionInfo> command)
        {
            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");

            var info = new SolutionInfo();

            info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
            info.FileName  = SolutionExplorerExtensions.GetSolutionDirectory();
            var projectGuids = SolutionExplorerExtensions.GetAllProjectGuids();

            SolutionExplorerExtensions.SaveSolution();
            foreach (var projectGuid in projectGuids)
            {
                SolutionExplorerExtensions.UnloadProject(projectGuid);
            }

            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, info.FileName, helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }).ContinueWith(_ =>
            {
                foreach (var projectGuid in projectGuids)
                {
                    SolutionExplorerExtensions.ReloadProject(projectGuid);
                }
            });
        }