コード例 #1
0
        /// <summary>
        /// Create an uninstall action with the given parameters
        /// </summary>
        /// <param name="archs"></param>
        /// <param name="oses"></param>
        /// <param name="productcode"></param>
        /// <param name="template"></param>
        /// <param name="objecttype"></param>
        /// <returns></returns>
        public static UninstallAction CreateUninstallAction(ICollection <ArchitectureConfiguration> archs, ICollection <OperatingSystemConfiguration> oses, string productcode, UninstallAction.TemplateType template, UninstallAction.WixObjectType objecttype)
        {
            var ua = new UninstallAction();

            foreach (ArchitectureConfiguration arch in archs)
            {
                ua.Architectures.Add(arch);
            }
            foreach (OperatingSystemConfiguration os in oses)
            {
                ua.OS.Add(os);
            }
            ua.ProductCode = productcode;
            ua.Template    = template;
            ua.WixObject   = objecttype;

            return(ua);
        }
コード例 #2
0
        private int UninstallActionExecution(Bundle bundle, UninstallAction.TemplateType template)
        {
            var DidInstallRun = false;
            var errorcode = 0;
            var currenterrorcode = 0;
            var rebootrequired = false;
            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Starting Template Type: {0} Bundle: {1}", template.ToString(), bundle.Name), Logger.MessageLevel.Information, AppName);
            ICollection<UninstallAction> _uas = UninstallActions.Where(x => x.Template == template).ToList();
            // For each uninstall item, only select those that are either before or after the main uninstall process
            // and match the machine OS and Architecture.  This is defined by the template parameter.
            // Only for given machine architecture
            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Uninstall actions found: {0}", _uas.Count().ToString(CultureInfo.InvariantCulture)), Logger.MessageLevel.Verbose, AppName);

            foreach (UninstallAction ua in _uas)
            {
                foreach (ArchitectureConfiguration ac in ua.Architectures)
                {
                    if (ac.Value == MachineArchitectureConfiguration.Value)
                    {
                        // Only get one OS version that matches to integer value from the OS
                        foreach (OperatingSystemConfiguration osc in ua.OS)
                        {
                            if (osc.Value == MachineOSVersion)
                            {
                                // Uninstall the selected package
                                foreach (Package package in bundle.Packages.Where(x => x.ProductCode == ua.ProductCode))
                                {
                                    if (!DoNotExecuteProcess) {
                                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Package found to match architecture and OS: {0}", package.ProductName), Logger.MessageLevel.Information, AppName);
                                        currenterrorcode = package.Uninstall();
                                        DidInstallRun = true;

                                        switch (currenterrorcode)
                                        {
                                            case 0:
                                                errorcode = currenterrorcode;
                                                break;
                                            case 3010:
                                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Reboot required"), Logger.MessageLevel.Information, AppName);
                                                errorcode = currenterrorcode;
                                                rebootrequired = true;
                                                break;
                                            default:
                                                Logger.Log(String.Format(CultureInfo.InvariantCulture, "Exitcode: {0}  Returned Error code: {1}", errorcode.ToString(CultureInfo.InvariantCulture), currenterrorcode.ToString(CultureInfo.InvariantCulture)), Logger.MessageLevel.Information, AppName);
                                                errorcode = errorcode == 3010 ? errorcode : currenterrorcode;
                                                break;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                if (
                    (errorcode != 0 || errorcode != 3010) // Did we get a non-zero error code
                    && DidInstallRun                      // Was an installer run?
                   )                                      // If so, we need to break the loop as the user likely has an action to take
                {
                    // Allow reboot required to drop out like a success.  This will allow all pre-requisite installers to complete regardless of a reboot being required.
                    //  - Break out on all other error codes.  Any other status is a hard error that needs to be handled outside of this process.
                    break;
                }
            }
            errorcode = errorcode != 0 ? errorcode : rebootrequired ? 3010 : errorcode;
            return errorcode;
        }
コード例 #3
0
        private int UninstallActionExecution(ICollection<Bundle> bundles, UninstallAction.TemplateType template)
        {
            var exitcode = -1;
            // Only iterate through selected bundles
            foreach (Bundle bundle in bundles)
            {
                exitcode = UninstallActionExecution(bundle, template);
            }

            return exitcode;
        }
コード例 #4
0
         /// <summary>
        /// Create an uninstall action with the given parameters
        /// </summary>
        /// <param name="archs"></param>
        /// <param name="oses"></param>
        /// <param name="productcode"></param>
        /// <param name="template"></param>
        /// <param name="objecttype"></param>
        /// <returns></returns>
        public static UninstallAction CreateUninstallAction(ICollection<ArchitectureConfiguration> archs, ICollection<OperatingSystemConfiguration> oses, string productcode, UninstallAction.TemplateType template, UninstallAction.WixObjectType objecttype)
        {
            var ua = new UninstallAction();
            foreach (ArchitectureConfiguration arch in archs) { ua.Architectures.Add(arch); }
            foreach (OperatingSystemConfiguration os in oses) { ua.OS.Add(os); }
            ua.ProductCode = productcode;
            ua.Template = template;
            ua.WixObject = objecttype;

            return ua;
        }