コード例 #1
0
        public void Restore(IEnumerable <RestoringProject> project)
        {
            string PaketSubCommand = "restore";

            foreach (RestoringProject p in project)
            {
                PaketSubCommand += $" --references-file \"{p.ReferenceFile}\" ";
            }

            try
            {
                PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), PaketSubCommand,
                                          (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
            }
            catch (PaketRuntimeException ex)
            {
                /* One of the known reasons for this block to get executed is that if the paket.exe is old then it is likely
                 * that --references-file is not supported and --references-files is supported instead. paket-4.8.4 for instance
                 */
                PaketOutputPane.OutputPane.OutputStringThreadSafe("Seems like you are using an older version of paket.exe. Trying restore with --references-files\n");
                PaketSubCommand = "restore --references-files";
                foreach (RestoringProject p in project)
                {
                    PaketSubCommand += $" {p.ReferenceFile} ";
                }
                PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), PaketSubCommand,
                                          (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
            }
        }
コード例 #2
0
 private void ConvertFromNuGet(object sender, EventArgs e)
 {
     RunCommandAndReloadAllProjects("paket-convert-from-nuget.html", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "convert-from-nuget",
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #3
0
 private void RemovePackage(object sender, EventArgs e)
 {
     RunCommandOnPackageAndReloadAllDependendProjects("paket-remove.html", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "remove " + info.PackageName,
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #4
0
 private void RemovePackageFromProject(object sender, EventArgs e)
 {
     RunCommandOnPackageInUnloadedProject("paket-remove.html#Removing-from-a-single-project", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "remove " + info.PackageName + " --project " + info.ReferencesFileName,
                                   (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.GetSolutionDirectory(), "update --group " + info.GroupName,
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #6
0
 private void Simplify(object sender, EventArgs e)
 {
     RunCommand("paket-simplify.html", info => // Should work without unload
     {
         PaketLauncher.LaunchPaket(info.Directory, "simplify",
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #7
0
 private void Restore(object sender, EventArgs e)
 {
     RunCommandAndReloadAllProjects("paket-restore.html", info =>
     {
         PaketLauncher.LaunchPaket(info.Directory, "restore",
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #8
0
 private void CheckForUpdates(object sender, EventArgs e)
 {
     RunCommand("paket-outdated.html", info =>
     {
         PaketLauncher.LaunchPaket(info.Directory, "outdated",
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #9
0
 private void Init(object sender, EventArgs e)
 {
     RunCommandAndReloadAllProjects("paket-init.html", info =>
     {
         PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "init",
                                   (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
     });
 }
コード例 #10
0
        public void Restore(IEnumerable <RestoringProject> project)
        {
            string PaketSubCommand = "restore";

            foreach (RestoringProject p in project)
            {
                PaketSubCommand += $" --references-file {p.ReferenceFile} ";
            }

            PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), PaketSubCommand,
                                      (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
        }
コード例 #11
0
        public static void ShowAddPackageDialog(string selectedFileName, string projectGuid = null)
        {
            Paket.Dependencies dependenciesFile = null;

            try
            {
                dependenciesFile = Dependencies.Locate(selectedFileName);
            }
            catch (Exception)
            {
                var dir = new System.IO.FileInfo(SolutionExplorerExtensions.GetSolutionFileName()).Directory.FullName;
                PaketLauncher.LaunchPaket(dir, "init",
                                          (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                dependenciesFile = Dependencies.Locate(selectedFileName);
            }

            var secondWindow = new AddPackage();

            //Create observable paket trace
            var paketTraceObs = Observable.Create <Logging.Trace>(observer =>
            {
                [email protected](x => observer.OnNext(x));
                return(Disposable.Create(() =>
                {
                }));
            });

            Action <NugetResult> addPackageToDependencies = result =>
            {
                if (projectGuid != null)
                {
                    var guid = Guid.Parse(projectGuid);
                    DteHelper.ExecuteCommand("File.SaveAll");
                    SolutionExplorerExtensions.UnloadProject(guid);
                    PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "add " + result.PackageName + " --project " + selectedFileName,
                                              (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                    SolutionExplorerExtensions.ReloadProject(guid);
                }
                else
                {
                    PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetSolutionDirectory(), "add " + result.PackageName,
                                              (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                }
            };

            Func <string, IObservable <string> > searchNuGet =
                searchText => Observable.Create <string>(obs =>
            {
                var disposable = new CancellationDisposable();

                dependenciesFile
                .SearchPackagesByName(
                    searchText,
                    FSharpOption <CancellationToken> .Some(disposable.Token),
                    FSharpOption <int> .None)
                .Subscribe(obs);

                return(disposable);
            });

            //TODO: Use interfaces?
            secondWindow.ViewModel = new AddPackageViewModel(searchNuGet, addPackageToDependencies, paketTraceObs);
            secondWindow.ShowDialog();
        }