示例#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.GetPaketDirectory();
            info.FileName  = SolutionExplorerExtensions.GetPaketDirectory();
            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(() =>
            {
            });
        }
示例#2
0
 private void ConvertFromNuGet(object sender, EventArgs e)
 {
     RunCommandAndReloadAllProjects("paket-convert-from-nuget.html", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "convert-from-nuget",
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
示例#3
0
 private void RemovePackageFromProject(object sender, EventArgs e)
 {
     RunCommandOnPackageInUnloadedProject("paket-remove.html#Removing-from-a-single-project", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "remove " + info.PackageName + " --project " + info.ReferencesFileName,
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
示例#4
0
 private void RemovePackage(object sender, EventArgs e)
 {
     RunCommandOnPackageAndReloadAllDependendProjects("paket-remove.html", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "remove " + info.PackageName,
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
示例#5
0
 private void UpdateGroup(object sender, EventArgs e)
 {
     RunCommandOnPackageAndReloadAllDependendProjects("paket-update.html#Updating-a-single-group", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "update --group " + info.GroupName,
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
示例#6
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.GetPaketDirectory();
            info.FileName  = SolutionExplorerExtensions.GetPaketDirectory();
            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);
                }
            });
        }