From c181fd20f40893d3759fe4779aa682efda7757b8 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Mon, 1 Aug 2016 09:49:21 -0500 Subject: [PATCH] (GH-885) Determine Installer by Overridable Method This allows a more comprehensive check in overrides of the uninstaller service. --- .../services/AutomaticUninstallerService.cs | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs index 6b051da13a..8561976a76 100644 --- a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs +++ b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs @@ -95,25 +95,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) uninstallExe = uninstallExe.remove_surrounding_quotes(); this.Log().Debug(() => " Uninstaller path is '{0}'".format_with(uninstallExe)); - - IInstaller installer = new CustomInstaller(); - - switch (key.InstallerType) - { - case InstallerType.Msi: - installer = new MsiInstaller(); - break; - case InstallerType.InnoSetup: - installer = new InnoSetupInstaller(); - break; - case InstallerType.Nsis: - installer = new NsisInstaller(); - break; - case InstallerType.InstallShield: - installer = new InstallShieldInstaller(); - break; - } - + IInstaller installer = get_installer_type(key, uninstallExe, uninstallArgs); this.Log().Debug(() => " Installer type is '{0}'".format_with(installer.GetType().Name)); if (key.InstallerType == InstallerType.Msi) @@ -124,7 +106,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) uninstallArgs = uninstallArgs.Replace("/I ", "/X "); uninstallArgs = uninstallArgs.Replace("/i ", "/X "); } - + if (!key.HasQuietUninstall) { //todo: ultimately we should merge keys @@ -194,5 +176,28 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config) } } } + + public virtual IInstaller get_installer_type(RegistryApplicationKey key, string uninstallExe, string uninstallArgs) + { + IInstaller installer = new CustomInstaller(); + + switch (key.InstallerType) + { + case InstallerType.Msi: + installer = new MsiInstaller(); + break; + case InstallerType.InnoSetup: + installer = new InnoSetupInstaller(); + break; + case InstallerType.Nsis: + installer = new NsisInstaller(); + break; + case InstallerType.InstallShield: + installer = new InstallShieldInstaller(); + break; + } + + return installer; + } } } \ No newline at end of file