Microsoft.VS.ConfigurationManager.Bundle.Uninstall C# (CSharp) Method

Uninstall() private method

private Uninstall ( ) : int
return int
        public int Uninstall()
        {
            var exitcode = -1;
            try
            {
                Logger.Log("Bundle uninstall started.", Logger.MessageLevel.Information, AppName);
                Logger.Log(String.Format(CultureInfo.InvariantCulture, "this.Installed: {0}", this.Installed), Logger.MessageLevel.Information, AppName);
                if (this.Installed)
                {
                    Logger.Log("Bundle uninstall called and bundle is installed.", Logger.MessageLevel.Information, AppName);
                    foreach (string file in Directory.GetFiles(LocalInstallLocation, "*.exe"))
                    {
                        var bundlelogfilename =  LogLocation + "_" + System.IO.Path.ChangeExtension(System.IO.Path.GetFileNameWithoutExtension(file), "log");
                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Installer: {0}", file), Logger.MessageLevel.Information, AppName);
                        var args = String.Format(CultureInfo.InvariantCulture, BundleUninstallArguments, bundlelogfilename);
                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Arguments: {0}", args), Logger.MessageLevel.Information, AppName);

                        Logger.LogWithOutput(string.Format("Uninstalling: {0}", file));
                        exitcode = Utility.ExecuteProcess(file, args);
                        if (exitcode == 0)
                            Logger.Log("Uninstall succeeded");
                        else
                        {
                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Uninstall failed with error code: {0}", exitcode), Logger.MessageLevel.Warning, AppName);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }

            Logger.Log("Bundle uninstall ended.", Logger.MessageLevel.Information, AppName);

            return exitcode;
        }

Usage Example

        public int Uninstall(Bundle bundle)
        {
            var exitcode = -1;
            var uninstallactionerrorcode = -1;

            if (!Processed)
            {
                GetDataFromPdb();
            }

            if (Releases.Where(x => x.Selected) != null)
            {
                try
                {
                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "Pre-requisite uninstall actions running"), Logger.MessageLevel.Information, AppName);
                    uninstallactionerrorcode = UninstallActionExecution(bundle, UninstallAction.TemplateType.Pre);
                    Logger.Log(String.Format(CultureInfo.InvariantCulture, "Pre-requisite uninstall actions finished"), Logger.MessageLevel.Information, AppName);
                    switch (uninstallactionerrorcode)
                    {
                    case 3010:      // Reboot required
                        break;

                    default:
                        if (!DoNotExecuteProcess)
                        {
                            exitcode = bundle.Uninstall();
                        }
                        else
                        {
                            Logger.Log(String.Format(CultureInfo.InvariantCulture, "Bundle uninstall method bypassed - DoNotExecute is true"), Logger.MessageLevel.Verbose, AppName);
                            exitcode = 0;
                        }
                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Post-requisite uninstall actions started"), Logger.MessageLevel.Information, AppName);
                        UninstallActionExecution(bundle, UninstallAction.TemplateType.Post);
                        Logger.Log(String.Format(CultureInfo.InvariantCulture, "Post-requisite uninstall actions finished"), Logger.MessageLevel.Information, AppName);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex, AppName);
                }
            }
            else
            {
                throw new ConfigurationManagerException("A release has not been selected for use with this method. Please use SelectedReleases to select a Release.");
            }

            return(exitcode);
        }
All Usage Examples Of Microsoft.VS.ConfigurationManager.Bundle::Uninstall