Exemplo n.º 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"));
            }
        }
Exemplo n.º 2
0
        private void Restore()
        {
            var dir          = SolutionExplorerExtensions.GetPaketDirectory();
            var dependencies = Dependencies.Locate(dir);

            var projects = SolutionExplorerExtensions.GetAllProjects()
                           .Select(p => new { ProjectName = p.Name, ReferenceFile = ProjectFile.FindReferencesFile(new FileInfo(p.FullName)) })
                           .Where(p => FSharpOption <string> .get_IsSome(p.ReferenceFile))
                           .Select(p => new RestoringProject(p.ProjectName, p.ReferenceFile.Value))
                           .ToList();

            restorer.Restore(projects);
        }
Exemplo n.º 3
0
        public static void ShowAddPackageDialog(string selectedFileName, string projectGuid = null)
        {
            Paket.Dependencies dependenciesFile = null;

            try
            {
                dependenciesFile = Dependencies.Locate(selectedFileName);
            }
            catch (Exception)
            {
                PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "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.GetPaketDirectory(), "add " + result.PackageName + " --project " + selectedFileName,
                                              (send, args) => PaketOutputPane.OutputPane.OutputStringThreadSafe(args.Data + "\n"));
                    SolutionExplorerExtensions.ReloadProject(guid);
                }
                else
                {
                    PaketLauncher.LaunchPaket(SolutionExplorerExtensions.GetPaketDirectory(), "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();
        }