internal PackageManagerUninstallProcess(IPackageUninstaller packageUninstaller, string packageInstallDirectory, SystemLockingType systemLockingType)
        {
            if (packageUninstaller == null) throw new ArgumentNullException("packageUninstaller");
            if (string.IsNullOrEmpty(packageInstallDirectory)) throw new ArgumentNullException("packageInstallDirectory");

            _packageUninstaller = packageUninstaller;
            _packageInstallDirectory = packageInstallDirectory;
            _systemLockingType = systemLockingType;

            _preUninstallValidationResult = new List<PackageFragmentValidationResult>();
        }
        internal PackageManagerUninstallProcess(IPackageUninstaller packageUninstaller, string packageInstallDirectory, SystemLockingType systemLockingType)
        {
            if (packageUninstaller == null)
            {
                throw new ArgumentNullException("packageUninstaller");
            }
            if (string.IsNullOrEmpty(packageInstallDirectory))
            {
                throw new ArgumentNullException("packageInstallDirectory");
            }

            _packageUninstaller      = packageUninstaller;
            _packageInstallDirectory = packageInstallDirectory;
            _systemLockingType       = systemLockingType;

            _preUninstallValidationResult = new List <PackageFragmentValidationResult>();
        }
Esempio n. 3
0
        public UninstallCommand(IUserInterface userInterface, IPackageUninstaller packageUninstaller)
        {
            if (userInterface == null)
            {
                throw new ArgumentNullException("userInterface");
            }

            if (packageUninstaller == null)
            {
                throw new ArgumentNullException("packageUninstaller");
            }

            this.userInterface = userInterface;
            this.packageUninstaller = packageUninstaller;

            this.Attributes = new CommandAttributes
            {
                CommandName = CommandName,
                AlternativeCommandNames = this.alternativeCommandNames,
                RequiredArguments = new[] { ArgumentNameNugetPackageId },
                PositionalArguments = new[] { ArgumentNameNugetPackageId },
                Description = Resources.UninstallCommand.CommandDescriptionText,
                Usage = string.Format("{0} <{1}>", CommandName, ArgumentNameNugetPackageId),
                Examples = new Dictionary<string, string>
                    {
                        {
                            string.Format("{0} <{1}>", CommandName, ArgumentNameNugetPackageId),
                            Resources.UninstallCommand.CommandExampleDescription1
                        }
                    },
                ArgumentDescriptions = new Dictionary<string, string>
                    {
                        { ArgumentNameNugetPackageId, Resources.UninstallCommand.ArgumentDescriptionNugetPackageId }
                    }
            };

            this.Arguments = new Dictionary<string, string>();
        }
Esempio n. 4
0
 public void Uninstall(IPackageUninstaller uninstaller)
 {
     // Do nothing. This package cannot be uninstalled!
 }
Esempio n. 5
0
 public void Uninstall(IPackageUninstaller uninstaller)
 {
     uninstaller.BasicUninstall();
 }
Esempio n. 6
0
        private PackageFragmentValidationResult DoInstall()
        {
            using (var transactionScope = TransactionsFacade.Create(true, TimeSpan.FromMinutes(30.0)))
            {
                string uninstallFilename = Path.Combine(this.PackageInstallDirectory,
                                                        PackageSystemSettings.UninstallFilename);

                Exception installException  = null;
                XElement  uninstallElements =
                    new XElement(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace,
                                                   PackageSystemSettings.PackageFragmentUninstallersElementName));
                try
                {
                    foreach (var kvp in _packageFramentInstallers)
                    {
                        List <XElement> uninstallInformation = kvp.Key.Install().ToList();

                        if (this.CanBeUninstalled)
                        {
                            XElement uninstallElement =
                                new XElement(XmlUtils.GetXName(PackageSystemSettings.XmlNamespace,
                                                               PackageSystemSettings.
                                                               PackageFragmentUninstallersAddElementName));
                            uninstallElement.Add(new XAttribute(PackageSystemSettings.UninstallerTypeAttributeName,
                                                                TypeManager.SerializeType(kvp.Value)));
                            uninstallElement.Add(uninstallInformation);

                            uninstallElements.Add(uninstallElement);
                        }
                    }
                }
                catch (Exception ex)
                {
                    installException = ex;
                    LoggingService.LogError("Package installation failed", ex);
                }
                finally
                {
                    if (this.CanBeUninstalled)
                    {
                        XDocument doc =
                            new XDocument(
                                new XElement(
                                    XmlUtils.GetXName(PackageSystemSettings.XmlNamespace,
                                                      PackageSystemSettings.PackageInstallerElementName),
                                    uninstallElements));
                        doc.SaveToFile(uninstallFilename);
                    }
                }


                if (installException != null)
                {
                    if (this.CanBeUninstalled)
                    {
                        IPackageUninstaller packageUninstaller =
                            this.PackageInstallerUninstallerFactory.CreateUninstaller(
                                this.ZipFilename, uninstallFilename,
                                this.PackageInstallDirectory,
                                TempDirectoryFacade.
                                CreateTempDirectory(),
                                this.FlushOnCompletion,
                                this.ReloadConsoleOnCompletion,
                                false,
                                this.PackageInformation);

                        List <PackageFragmentValidationResult> validationResult = null;
                        try
                        {
                            validationResult = packageUninstaller.Validate().ToList();
                        }
                        catch (Exception ex)
                        {
                            return(new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex));
                        }


                        if (validationResult.Count == 0)
                        {
                            try
                            {
                                packageUninstaller.Uninstall(SystemLockingType.None);
                            }
                            catch (Exception ex)
                            {
                                return(new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex));
                            }
                        }
                        else
                        {
                            LoggingService.LogError(LogTitle, "Failed to perform installation rollback.");
                            foreach (var valResult in validationResult)
                            {
                                if (valResult.Exception != null)
                                {
                                    LoggingService.LogError(LogTitle, new InvalidOperationException(valResult.Message ?? string.Empty, valResult.Exception));
                                }
                                else
                                {
                                    LoggingService.LogWarning(LogTitle, valResult.Message);
                                }
                            }

                            return(new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal,
                                                                       "Could not perform installation rollback. The details are in the log.")
                            {
                                InnerResult = validationResult
                            });
                        }
                    }

                    return(new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal,
                                                               installException));
                }
                transactionScope.Complete();
            }
            return(null);
        }
Esempio n. 7
0
 public void Uninstall(IPackageUninstaller uninstaller)
 {
     uninstaller.BasicUninstall();
 }
Esempio n. 8
0
 public void Uninstall(IPackageUninstaller uninstaller)
 {
     // Do nothing. This package cannot be uninstalled!
 }
Esempio n. 9
0
        public PackageInstaller(ApplicationInformation applicationInformation, IFilesystemAccessor filesystemAccessor, IPackageConfigurationAccessor packageConfigurationAccessor, IPackageRepositoryBrowser packageRepositoryBrowser, IPowerShellExecutor powerShellExecutor, IInstallationLogicProvider installationLogicProvider, IPackageUninstaller packageUninstaller, INugetPackageExtractor nugetPackageExtractor, IPackageConfigurationTransformationService packageConfigurationTransformationService, IConfigurationFileTransformationService configurationFileTransformationService)
        {
            if (applicationInformation == null)
            {
                throw new ArgumentNullException("applicationInformation");
            }

            if (filesystemAccessor == null)
            {
                throw new ArgumentNullException("filesystemAccessor");
            }

            if (packageConfigurationAccessor == null)
            {
                throw new ArgumentNullException("packageConfigurationAccessor");
            }

            if (packageRepositoryBrowser == null)
            {
                throw new ArgumentNullException("packageRepositoryBrowser");
            }

            if (powerShellExecutor == null)
            {
                throw new ArgumentNullException("powerShellExecutor");
            }

            if (installationLogicProvider == null)
            {
                throw new ArgumentNullException("installationLogicProvider");
            }

            if (packageUninstaller == null)
            {
                throw new ArgumentNullException("packageUninstaller");
            }

            if (nugetPackageExtractor == null)
            {
                throw new ArgumentNullException("nugetPackageExtractor");
            }

            if (packageConfigurationTransformationService == null)
            {
                throw new ArgumentNullException("packageConfigurationTransformationService");
            }

            if (configurationFileTransformationService == null)
            {
                throw new ArgumentNullException("configurationFileTransformationService");
            }

            this.applicationInformation = applicationInformation;
            this.filesystemAccessor = filesystemAccessor;
            this.packageConfigurationAccessor = packageConfigurationAccessor;
            this.packageRepositoryBrowser = packageRepositoryBrowser;
            this.powerShellExecutor = powerShellExecutor;
            this.installationLogicProvider = installationLogicProvider;
            this.packageUninstaller = packageUninstaller;
            this.nugetPackageExtractor = nugetPackageExtractor;
            this.packageConfigurationTransformationService = packageConfigurationTransformationService;
            this.configurationFileTransformationService = configurationFileTransformationService;
        }