private IEnumerable <PackageResult> report_registry_programs(ChocolateyConfiguration config, IEnumerable <IPackage> list)
        {
            var itemsToRemoveFromMachine = list.Select(package => _packageInfoService.get_package_information(package)).
                                           Where(p => p.RegistrySnapshot != null).
                                           Select(p => p.RegistrySnapshot.RegistryKeys.FirstOrDefault()).
                                           Where(p => p != null).
                                           Select(p => p.DisplayName).ToList();

            var count            = 0;
            var machineInstalled = _registryService.get_installer_keys().RegistryKeys.
                                   Where((p) => p.is_in_programs_and_features() && !itemsToRemoveFromMachine.Contains(p.DisplayName)).
                                   OrderBy((p) => p.DisplayName).Distinct();

            this.Log().Info(() => "");
            foreach (var key in machineInstalled)
            {
                if (config.RegularOutput)
                {
                    this.Log().Info("{0}|{1}".format_with(key.DisplayName, key.DisplayVersion));
                    if (config.Verbose)
                    {
                        this.Log().Info(" InstallLocation: {0}{1} Uninstall:{2}".format_with(key.InstallLocation.escape_curly_braces(), Environment.NewLine, key.UninstallString.escape_curly_braces()));
                    }
                }
                count++;

                yield return(new PackageResult(key.DisplayName, key.DisplayName, key.InstallLocation));
            }

            if (config.RegularOutput)
            {
                this.Log().Warn(() => @"{0} applications not managed with Chocolatey.".format_with(count));
            }
        }
 public void list_pins(IPackageManager packageManager, ChocolateyConfiguration config)
 {
     foreach (var pkg in _nugetService.list_run(config))
     {
         var pkgInfo = _packageInfoService.get_package_information(pkg.Package);
         if (pkgInfo != null && pkgInfo.IsPinned)
         {
             this.Log().Info(() => "{0}|{1}".format_with(pkgInfo.Package.Id, pkgInfo.Package.Version));
         }
     }
 }
Example #3
0
        public void list_pins(IPackageManager packageManager, ChocolateyConfiguration config)
        {
            var localPackages = _nugetService.list_run(config, logResults: false);

            foreach (var pkg in localPackages.or_empty_list_if_null())
            {
                var pkgInfo = _packageInfoService.get_package_information(pkg.Value.Package);
                if (pkgInfo != null && pkgInfo.IsPinned)
                {
                    this.Log().Info(() => "{0}|{1}".format_with(pkgInfo.Package.Id, pkgInfo.Package.Version));
                }
            }
        }
Example #4
0
        public void run(PackageResult packageResult, ChocolateyConfiguration config)
        {
            if (!config.Features.AutoUninstaller)
            {
                this.Log().Info(" Skipping auto uninstaller - AutoUninstaller feature is not enabled.");
                return;
            }

            var packageLocation = packageResult.InstallLocation;

            if (!string.IsNullOrWhiteSpace(packageLocation))
            {
                var skipFiles = _fileSystem.get_files(packageLocation, SKIP_FILE_NAME + "*", SearchOption.AllDirectories).Where(p => !p.to_lower().contains("\\templates\\"));
                if (skipFiles.Count() != 0)
                {
                    this.Log().Info(" Skipping auto uninstaller - Package contains a skip file ('{0}').".format_with(SKIP_FILE_NAME));
                    return;
                }
            }

            var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);

            if (pkgInfo.RegistrySnapshot == null)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry snapshot.");
                return;
            }

            var registryKeys = pkgInfo.RegistrySnapshot.RegistryKeys;

            if (registryKeys == null || registryKeys.Count == 0)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry keys in snapshot.");
                return;
            }

            var package = pkgInfo.Package;

            if (package == null)
            {
                this.Log().Info(" Skipping auto uninstaller - No package in package information.");
                return;
            }

            this.Log().Info(" Running auto uninstaller...");
            if (WaitForCleanup)
            {
                this.Log().Debug("  Sleeping for {0} seconds to allow Windows to finish cleaning up.".format_with(SLEEP_TIME));
                Thread.Sleep((int)TimeSpan.FromSeconds(SLEEP_TIME).TotalMilliseconds);
            }

            foreach (var key in registryKeys.or_empty_list_if_null())
            {
                var packageCacheLocation = _fileSystem.combine_paths(_fileSystem.get_full_path(config.CacheLocation), package.Id, package.Version.to_string());
                remove(key, config, packageResult, packageCacheLocation);
            }
        }
Example #5
0
        public virtual void list_pins(ChocolateyConfiguration config)
        {
            var quiet = config.QuietOutput;

            config.QuietOutput = true;
            var packages = _packageService.list_run(config).ToList();

            config.QuietOutput = quiet;
            bool showPinned = !config.PinCommand.Unpinned;

            foreach (var pkg in packages.or_empty_list_if_null())
            {
                var pkgInfo = _packageInfoService.get_package_information(pkg.Package);
                if (pkgInfo != null && pkgInfo.IsPinned == showPinned)
                {
                    this.Log().Info(() => "{0}|{1}".format_with(pkgInfo.Package.Id, pkgInfo.Package.Version));
                }
            }
        }
Example #6
0
        public virtual void list_pins(IPackageManager packageManager, ChocolateyConfiguration config)
        {
            var input = config.Input;

            config.Input = string.Empty;
            var quiet = config.QuietOutput;

            config.QuietOutput = true;
            var packages = _nugetService.list_run(config).ToList();

            config.QuietOutput = quiet;
            config.Input       = input;

            foreach (var pkg in packages.or_empty_list_if_null())
            {
                var pkgInfo = _packageInfoService.get_package_information(pkg.Package);
                if (pkgInfo != null && pkgInfo.IsPinned)
                {
                    this.Log().Info(() => "{0}|{1}".format_with(pkgInfo.Package.Id, pkgInfo.Package.Version));
                }
            }
        }
        private void report_registry_programs(ChocolateyConfiguration config, ConcurrentDictionary <string, PackageResult> list)
        {
            var itemsToRemoveFromMachine = new List <string>();

            foreach (var packageResult in list)
            {
                if (packageResult.Value != null && packageResult.Value.Package != null)
                {
                    var pkginfo = _packageInfoService.get_package_information(packageResult.Value.Package);
                    if (pkginfo.RegistrySnapshot == null)
                    {
                        continue;
                    }
                    var key = pkginfo.RegistrySnapshot.RegistryKeys.FirstOrDefault();
                    if (key != null)
                    {
                        itemsToRemoveFromMachine.Add(key.DisplayName);
                    }
                }
            }
            var machineInstalled = _registryService.get_installer_keys().RegistryKeys.Where((p) => p.is_in_programs_and_features() && !itemsToRemoveFromMachine.Contains(p.DisplayName)).OrderBy((p) => p.DisplayName).Distinct().ToList();

            if (machineInstalled.Count != 0)
            {
                this.Log().Info(() => "");
                foreach (var key in machineInstalled.or_empty_list_if_null())
                {
                    this.Log().Info("{0}|{1}".format_with(key.DisplayName, key.DisplayVersion));
                    if (config.Verbose)
                    {
                        this.Log().Info(" InstallLocation: {0}{1} Uninstall:{2}".format_with(key.InstallLocation.escape_curly_braces(), Environment.NewLine, key.UninstallString.escape_curly_braces()));
                    }
                }
                this.Log().Warn(() => @"{0} applications not managed with Chocolatey.".format_with(machineInstalled.Count));
            }
        }
        public void run(PackageResult packageResult, ChocolateyConfiguration config)
        {
            if (!config.Features.AutoUninstaller)
            {
                this.Log().Info(" Skipping auto uninstaller - AutoUninstaller feature is not enabled.");
                return;
            }

            var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);

            if (pkgInfo.RegistrySnapshot == null)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry snapshot.");
                return;
            }

            var registryKeys = pkgInfo.RegistrySnapshot.RegistryKeys;

            if (registryKeys == null || registryKeys.Count == 0)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry keys in snapshot.");
                return;
            }

            this.Log().Info(" Running auto uninstaller...");
            if (WaitForCleanup)
            {
                this.Log().Debug("  Sleeping for {0} seconds to allow Windows to finish cleaning up.".format_with(SLEEP_TIME));
                Thread.Sleep((int)TimeSpan.FromSeconds(SLEEP_TIME).TotalMilliseconds);
            }

            foreach (var key in registryKeys.or_empty_list_if_null())
            {
                var packageCacheLocation = _fileSystem.combine_paths(_fileSystem.get_full_path(config.CacheLocation), pkgInfo.Package.Id, pkgInfo.Package.Version.to_string());
                remove(key, config, packageResult, packageCacheLocation);
            }
        }
Example #9
0
        public ConcurrentDictionary <string, PackageResult> upgrade_run(ChocolateyConfiguration config, Action <PackageResult> continueAction, bool performAction)
        {
            _fileSystem.create_directory_if_not_exists(ApplicationParameters.PackagesLocation);
            var packageInstalls = new ConcurrentDictionary <string, PackageResult>();

            SemanticVersion version        = config.Version != null ? new SemanticVersion(config.Version) : null;
            var             packageManager = NugetCommon.GetPackageManager(
                config,
                _nugetLogger,
                installSuccessAction: (e) =>
            {
                var pkg     = e.Package;
                var results = packageInstalls.GetOrAdd(pkg.Id.to_lower(), new PackageResult(pkg, e.InstallPath));
                results.Messages.Add(new ResultMessage(ResultType.Debug, ApplicationParameters.Messages.ContinueChocolateyAction));

                if (continueAction != null)
                {
                    continueAction.Invoke(results);
                }
            },
                uninstallSuccessAction: null);

            var configIgnoreDependencies = config.IgnoreDependencies;

            set_package_names_if_all_is_specified(config, () => { config.IgnoreDependencies = true; });
            config.IgnoreDependencies = configIgnoreDependencies;


            foreach (string packageName in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null())
            {
                //todo: get smarter about realizing multiple versions have been installed before and allowing that

                remove_existing_rollback_directory(packageName);

                IPackage installedPackage = packageManager.LocalRepository.FindPackage(packageName);

                if (installedPackage == null)
                {
                    //todo v1 Deprecation - reimplement error
                    //string logMessage = "{0} is not installed. Cannot upgrade a non-existent package.".format_with(packageName);
                    //var results = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, null, null));
                    //results.Messages.Add(new ResultMessage(ResultType.Error, logMessage));

                    //if (config.RegularOuptut) this.Log().Error(ChocolateyLoggers.Important, logMessage);
                    //continue;

                    string logMessage = @"
DEPRECATION NOTICE - Upgrade will no longer install non-installed 
packages as of version 1.0.0. That is what the install command is for.


{0} is not installed. Installing...".format_with(packageName);

                    if (config.RegularOuptut)
                    {
                        this.Log().Warn(ChocolateyLoggers.Important, logMessage);
                    }

                    var packageNames = config.PackageNames;
                    config.PackageNames = packageName;
                    var installResults = install_run(config, continueAction);
                    foreach (var packageResult in installResults)
                    {
                        packageInstalls.GetOrAdd(packageResult.Key, packageResult.Value);
                    }
                    config.PackageNames = packageNames;
                    continue;
                }

                var pkgInfo = _packageInfoService.get_package_information(installedPackage);
                if (pkgInfo != null && pkgInfo.IsPinned)
                {
                    string logMessage = "{0} is pinned. Skipping pinned package.".format_with(packageName);
                    var    results    = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, null, null));
                    results.Messages.Add(new ResultMessage(ResultType.Warn, logMessage));
                    results.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage));
                    if (config.RegularOuptut)
                    {
                        this.Log().Warn(ChocolateyLoggers.Important, logMessage);
                    }
                    continue;
                }

                IPackage availablePackage = packageManager.SourceRepository.FindPackage(packageName, version, config.Prerelease, allowUnlisted: false);
                if (availablePackage == null)
                {
                    string logMessage = "{0} was not found with the source(s) listed.{1} If you specified a particular version and are receiving this message, it is possible that the package name exists but the version does not.{1} Version: \"{2}\"{1} Source(s): \"{3}\"".format_with(packageName, Environment.NewLine, config.Version, config.Sources);
                    var    results    = packageInstalls.GetOrAdd(packageName, new PackageResult(packageName, version.to_string(), null));

                    if (config.UpgradeCommand.FailOnUnfound)
                    {
                        results.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
                        if (config.RegularOuptut)
                        {
                            this.Log().Error(ChocolateyLoggers.Important, logMessage);
                        }
                    }
                    else
                    {
                        results.Messages.Add(new ResultMessage(ResultType.Warn, logMessage));
                        results.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage));
                        if (config.RegularOuptut)
                        {
                            this.Log().Warn(ChocolateyLoggers.Important, logMessage);
                        }
                    }

                    continue;
                }

                if ((installedPackage.Version > availablePackage.Version))
                {
                    string logMessage = "{0} v{1} is newer than the most recent.{2} You must be smarter than the average bear...".format_with(installedPackage.Id, installedPackage.Version, Environment.NewLine);
                    var    results    = packageInstalls.GetOrAdd(packageName, new PackageResult(installedPackage, ApplicationParameters.PackagesLocation));
                    results.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage));

                    if (config.RegularOuptut)
                    {
                        this.Log().Info(ChocolateyLoggers.Important, logMessage);
                    }
                    continue;
                }

                if ((installedPackage.Version == availablePackage.Version))
                {
                    string logMessage = "{0} v{1} is the latest version available based on your source(s).".format_with(installedPackage.Id, installedPackage.Version);
                    var    results    = packageInstalls.GetOrAdd(packageName, new PackageResult(installedPackage, ApplicationParameters.PackagesLocation));
                    if (results.Messages.Count((p) => p.Message == ApplicationParameters.Messages.ContinueChocolateyAction) == 0)
                    {
                        results.Messages.Add(new ResultMessage(ResultType.Inconclusive, logMessage));
                    }

                    if (config.RegularOuptut)
                    {
                        this.Log().Info(logMessage);
                    }
                    if (!config.Force)
                    {
                        continue;
                    }
                }

                if (availablePackage.Version > installedPackage.Version || config.Force)
                {
                    if (availablePackage.Version > installedPackage.Version)
                    {
                        if (config.RegularOuptut)
                        {
                            this.Log().Warn("You have {0} v{1} installed. Version {2} is available based on your source(s)".format_with(installedPackage.Id, installedPackage.Version, availablePackage.Version));
                        }
                        else
                        {
                            //last one is whether this package is pinned or not
                            this.Log().Info("{0}|{1}|{2}|{3}".format_with(installedPackage.Id, installedPackage.Version, availablePackage.Version, "false"));
                        }
                    }

                    if (performAction)
                    {
                        using (packageManager.SourceRepository.StartOperation(
                                   RepositoryOperationNames.Update,
                                   packageName,
                                   version == null ? null : version.ToString()))
                        {
                            backup_existing_version(config, installedPackage);
                            packageManager.UpdatePackage(availablePackage, updateDependencies: !config.IgnoreDependencies, allowPrereleaseVersions: config.Prerelease);
                        }
                    }
                }
            }

            return(packageInstalls);
        }
        public void run(PackageResult packageResult, ChocolateyConfiguration config)
        {
            if (!config.Features.AutoUninstaller)
            {
                this.Log().Info(" Skipping auto uninstaller - AutoUninstaller feature is not enabled.");
                return;
            }

            var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);

            if (pkgInfo.RegistrySnapshot == null)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry snapshot.");
                return;
            }

            var registryKeys = pkgInfo.RegistrySnapshot.RegistryKeys;

            if (registryKeys == null || registryKeys.Count == 0)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry keys in snapshot.");
                return;
            }

            this.Log().Info(" Running auto uninstaller...");
            if (WaitForCleanup)
            {
                this.Log().Debug("Sleeping for {0} seconds to allow Windows to finish cleaning up.".format_with(SLEEP_TIME));
                Thread.Sleep((int)TimeSpan.FromSeconds(SLEEP_TIME).TotalMilliseconds);
            }

            foreach (var key in registryKeys.or_empty_list_if_null())
            {
                this.Log().Debug(() => " Preparing uninstall key '{0}'".format_with(key.UninstallString));

                if ((!string.IsNullOrWhiteSpace(key.InstallLocation) && !_fileSystem.directory_exists(key.InstallLocation)) || !_registryService.installer_value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation))
                {
                    this.Log().Info(" Skipping auto uninstaller - The application appears to have been uninstalled already by other means.");
                    this.Log().Debug(() => " Searched for install path '{0}' - found? {1}".format_with(key.InstallLocation.escape_curly_braces(), _fileSystem.directory_exists(key.InstallLocation)));
                    this.Log().Debug(() => " Searched for registry key '{0}' value '{1}' - found? {2}".format_with(key.KeyPath.escape_curly_braces(), ApplicationParameters.RegistryValueInstallLocation, _registryService.installer_value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation)));
                    continue;
                }

                // split on " /" and " -" for quite a bit more accuracy
                IList <string> uninstallArgsSplit = key.UninstallString.to_string().Split(new[] { " /", " -" }, StringSplitOptions.RemoveEmptyEntries).ToList();
                var            uninstallExe       = uninstallArgsSplit.DefaultIfEmpty(string.Empty).FirstOrDefault();
                var            uninstallArgs      = key.UninstallString.to_string().Replace(uninstallExe.to_string(), string.Empty);
                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;
                }

                this.Log().Debug(() => " Installer type is '{0}'".format_with(installer.GetType().Name));

                if (key.InstallerType == InstallerType.Msi)
                {
                    // because sometimes the key is set with /i to allow for modify :/
                    uninstallArgs = uninstallArgs.Replace("/I{", "/X{");
                    uninstallArgs = uninstallArgs.Replace("/i{", "/X{");
                    uninstallArgs = uninstallArgs.Replace("/I ", "/X ");
                    uninstallArgs = uninstallArgs.Replace("/i ", "/X ");
                }

                if (!key.HasQuietUninstall)
                {
                    //todo: ultimately we should merge keys
                    uninstallArgs += " " + installer.build_uninstall_command_arguments();
                }

                var logLocation = _fileSystem.combine_paths(_fileSystem.get_full_path(config.CacheLocation), "chocolatey", pkgInfo.Package.Id, pkgInfo.Package.Version.to_string());
                _fileSystem.create_directory_if_not_exists(_fileSystem.get_directory_name(logLocation));
                uninstallArgs = uninstallArgs.Replace(InstallTokens.PACKAGE_LOCATION, logLocation);

                this.Log().Debug(() => " Args are '{0}'".format_with(uninstallArgs));

                if (!key.HasQuietUninstall && installer.GetType() == typeof(CustomInstaller))
                {
                    var skipUninstaller = true;
                    if (config.PromptForConfirmation)
                    {
                        var selection = InteractivePrompt.prompt_for_confirmation("Uninstall may not be silent (could not detect). Proceed?", new[] { "yes", "no" }, defaultChoice: null, requireAnswer: true);
                        if (selection.is_equal_to("no"))
                        {
                            skipUninstaller = false;
                        }
                    }

                    if (skipUninstaller)
                    {
                        this.Log().Info(" Skipping auto uninstaller - Installer type was not detected and no silent uninstall key exists.");
                        return;
                    }
                }

                var exitCode = _commandExecutor.execute(
                    uninstallExe,
                    uninstallArgs.trim_safe(),
                    config.CommandExecutionTimeoutSeconds,
                    (s, e) =>
                {
                    if (e == null || string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    this.Log().Info(() => " [AutoUninstaller] {0}".format_with(e.Data));
                },
                    (s, e) =>
                {
                    if (e == null || string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    this.Log().Error(() => " [AutoUninstaller] {0}".format_with(e.Data));
                },
                    updateProcessPath: false);

                if (!installer.ValidUninstallExitCodes.Contains(exitCode))
                {
                    Environment.ExitCode = exitCode;
                    string logMessage = " Auto uninstaller failed. Please remove machine installation manually.{0} Exit code was {1}".format_with(Environment.NewLine, exitCode);
                    this.Log().Error(() => logMessage);
                    packageResult.Messages.Add(new ResultMessage(config.Features.FailOnAutoUninstaller ? ResultType.Error : ResultType.Warn, logMessage));
                }
                else
                {
                    this.Log().Info(() => " Auto uninstaller has successfully uninstalled {0} or detected previous uninstall.".format_with(packageResult.Package.Id));
                }
            }
        }
Example #11
0
        public void run(PackageResult packageResult, ChocolateyConfiguration config)
        {
            if (!config.Features.AutoUninstaller)
            {
                this.Log().Info(" Skipping auto uninstaller - AutoUninstaller feature is not enabled.");
                return;
            }

            var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);

            if (pkgInfo.RegistrySnapshot == null)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry snapshot.");
                return;
            }

            var registryKeys = pkgInfo.RegistrySnapshot.RegistryKeys;

            if (registryKeys == null || registryKeys.Count == 0)
            {
                this.Log().Info(" Skipping auto uninstaller - No registry keys in snapshot.");
                return;
            }

            this.Log().Info(" Running auto uninstaller...");

            foreach (var key in registryKeys.or_empty_list_if_null())
            {
                this.Log().Debug(() => " Preparing uninstall key '{0}'".format_with(key.UninstallString));

                if ((!string.IsNullOrWhiteSpace(key.InstallLocation) && !_fileSystem.directory_exists(key.InstallLocation)) || !_registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation))
                {
                    this.Log().Info(" Skipping auto uninstaller - The application appears to have been uninstalled already by other means.");
                    this.Log().Debug(() => " Searched for install path '{0}' - found? {1}".format_with(key.InstallLocation.escape_curly_braces(), _fileSystem.directory_exists(key.InstallLocation)));
                    this.Log().Debug(() => " Searched for registry key '{0}' value '{1}' - found? {2}".format_with(key.KeyPath.escape_curly_braces(), ApplicationParameters.RegistryValueInstallLocation, _registryService.value_exists(key.KeyPath, ApplicationParameters.RegistryValueInstallLocation)));
                    continue;
                }

                // split on " /" and " -" for quite a bit more accuracy
                IList <string> uninstallArgsSplit = key.UninstallString.to_string().Split(new[] { " /", " -" }, StringSplitOptions.RemoveEmptyEntries).ToList();
                var            uninstallExe       = uninstallArgsSplit.DefaultIfEmpty(string.Empty).FirstOrDefault();
                var            uninstallArgs      = key.UninstallString.to_string().Replace(uninstallExe.to_string(), string.Empty);
                uninstallExe = uninstallExe.remove_surrounding_quotes();
                this.Log().Debug(() => " Uninstaller path is '{0}'".format_with(uninstallExe));

                if (!key.HasQuietUninstall)
                {
                    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;

                    default:
                        // skip
                        break;
                    }

                    this.Log().Debug(() => " Installer type is '{0}'".format_with(installer.GetType().Name));


                    //todo: ultimately we should merge keys with logging
                    uninstallArgs += " " + installer.build_uninstall_command_arguments();
                }

                if (key.InstallerType == InstallerType.Msi)
                {
                    //because sometimes the key is set with /i to allow for modify :/
                    uninstallArgs = uninstallArgs.Replace("/I{", "/X{");
                    uninstallArgs = uninstallArgs.Replace("/i{", "/X{");
                    uninstallArgs = uninstallArgs.Replace("/I ", "/X ");
                    uninstallArgs = uninstallArgs.Replace("/i ", "/X ");
                }

                this.Log().Debug(() => " Args are '{0}'".format_with(uninstallArgs));

                var exitCode = _commandExecutor.execute(
                    uninstallExe,
                    uninstallArgs.trim_safe(),
                    config.CommandExecutionTimeoutSeconds,
                    (s, e) =>
                {
                    if (e == null || string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    this.Log().Debug(() => " [AutoUninstaller] {0}".format_with(e.Data));
                },
                    (s, e) =>
                {
                    if (e == null || string.IsNullOrWhiteSpace(e.Data))
                    {
                        return;
                    }
                    this.Log().Error(() => " [AutoUninstaller] {0}".format_with(e.Data));
                },
                    updateProcessPath: false);

                if (exitCode != 0)
                {
                    Environment.ExitCode = exitCode;
                    string logMessage = " Auto uninstaller failed. Please remove machine installation manually.";
                    this.Log().Error(() => logMessage);
                    packageResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
                }
                else
                {
                    this.Log().Info(() => " Auto uninstaller has successfully uninstalled {0} from your machine.".format_with(packageResult.Package.Id));
                }
            }
        }