Skip to content

Commit

Permalink
(GH-885) Determine Installer by Overridable Method
Browse files Browse the repository at this point in the history
This allows a more comprehensive check in overrides of the uninstaller
service.
  • Loading branch information
ferventcoder committed Aug 1, 2016
1 parent be903e4 commit c181fd2
Showing 1 changed file with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
}
}

0 comments on commit c181fd2

Please sign in to comment.