コード例 #1
0
        protected virtual void Preprocess()
        {
            CheckSolutionIsOpen();
            UpdateActiveSourceRepository(Source);
            DetermineFileConflictAction();

            ParseUserInputForVersion();

            if (!projectSpecified)
            {
                projects = ConsoleHost.GetNuGetProjects().ToList();
            }
            else
            {
                NuGetProject project = ConsoleHost.GetNuGetProject(ProjectName);
                if (project == null)
                {
                    ThrowProjectNotOpenTerminatingError();
                }

                projects = new List <NuGetProject> {
                    project
                };
            }

            if (Reinstall)
            {
                ActionType = NuGetActionType.Reinstall;
            }
            else
            {
                ActionType = NuGetActionType.Update;
            }
        }
コード例 #2
0
        protected void Preprocess()
        {
            ThrowErrorIfProjectNotOpen();
            UpdateActiveSourceRepository(Source);
            project = ConsoleHost.GetNuGetProject(ProjectName);
            DetermineFileConflictAction();

            ParseUserInputForId();
            ParseUserInputForVersion();

            // The following update to ActiveSourceRepository may get overwritten if the 'Id' was just a path to a nupkg
            if (readFromDirectPackagePath)
            {
                UpdateActiveSourceRepository(Source);
            }

            ActionType = NuGetActionType.Install;
        }
コード例 #3
0
        List <NuGetProject> GetNuGetProjects()
        {
            if (HasSelectedProjectName())
            {
                return new List <NuGetProject> {
                           ConsoleHost.GetNuGetProject(ProjectName)
                }
            }
            ;

            return(ConsoleHost.GetNuGetProjects().ToList());
        }

        bool HasSelectedProjectName()
        {
            return(ProjectName != null);
        }

        void WriteInstalledPackages()
        {
            CheckSolutionIsOpen();

            var packagesToDisplay = GetInstalledPackagesAsync(projects, Filter, Skip, First, ConsoleHost.Token);

            WriteInstalledPackages(packagesToDisplay.Result);
        }

        void WriteInstalledPackages(Dictionary <NuGetProject, IEnumerable <NuGet.Packaging.PackageReference> > packages)
        {
            List <PowerShellInstalledPackage> view = PowerShellInstalledPackage.GetPowerShellPackageView(packages, ConsoleHost.SolutionManager, ConsoleHost.Settings);

            if (view.Any())
            {
                WritePackagesToOutputPipeline(view);
            }
            else
            {
                Log(MessageLevel.Info, GettextCatalog.GetString("No packages installed."));
            }
        }
        void UninstallPackage()
        {
            NuGetProject project = ConsoleHost.GetNuGetProject(ProjectName);

            UninstallPackageByIdAsync(project, Id, CreateUninstallContext(), this, WhatIf.IsPresent).Wait();
        }