static void Main(string[] args) { if (args.Length != 1 || string.IsNullOrEmpty(args[0])) { Console.WriteLine("Usage:\nClickOnceUninstaller appName"); return; } var appName = args[0]; var uninstallInfo = UninstallInfo.Find(appName); if (uninstallInfo == null) { Console.WriteLine("Could not find application \"{0}\"", appName); return; } Console.WriteLine("Uninstalling application \"{0}\"", appName); var uninstaller = new Uninstaller(); uninstaller.Uninstall(uninstallInfo); Console.WriteLine("Uninstall complete"); }
public static ActionResult UninstallClickOnce(Session session) { session.Log("Begin to uninstall ClickOnce deployment"); var appName = session["CLICKONCEAPPNAME"]; if (string.IsNullOrEmpty(appName)) { session.Log("Please set property CLICKONCEAPPNAME."); return(ActionResult.Failure); } try { var uninstallInfo = UninstallInfo.Find(appName); if (uninstallInfo == null) { session.Log("No uninstall information found for " + appName); return(ActionResult.NotExecuted); } session.Log("Uninstalling " + appName); var uninstaller = new Uninstaller(); uninstaller.Uninstall(uninstallInfo); } catch (Exception ex) { session.Log("ERROR in ClickOnceUninstaller custom action:\n {0}", ex.ToString()); return(ActionResult.Failure); } return(ActionResult.Success); }
private IEnumerable <string> FindComponentsToRemove(UninstallInfo info) { var token = info.GetPublicKeyToken(); var installer = info.GetInstallerName(); var exeName = info.GetExecutableName(); var candidates = _registry.Components.Where(c => c.Key.Contains(token)); var components = new List <ClickOnceRegistry.Component>(); // There should be a lone node for the installer itself. components.AddRange(candidates.Where(c => c.Identity.Contains(installer))); // Find the component that matches the public key and executable name. // Note this assumes different editions of your program have different names, // and that there will be only one match for a given key and exe name. var exeComponent = candidates.Where(c => c.Identity.Contains(exeName)).FirstOrDefault(); if (exeComponent != null) { // Find the nodes that depend on the exe and add them - they will // be for the installer .application file and their dependencies should // cover everything that needs to be removed. components.AddRange(candidates .Where(c => c.Dependencies.Any(d => d.Key == exeComponent.Key))); } var toRemove = new List <ClickOnceRegistry.Component>(); foreach (var component in components) { toRemove.Add(component); foreach (var dependency in component.Dependencies) { if (toRemove.Any(d => d.Key == dependency.Key)) { continue; // already in the list } if (_registry.Components.All(c => c.Key != dependency.Key)) { continue; // not a public component } var mark = _registry.Marks.FirstOrDefault(m => m.Key == dependency.Key); if (mark != null && mark.Implications.Any(i => components.All(c => c.Key != i.Name))) { // don't remove because other apps depend on this continue; } toRemove.Add(dependency); } } return(toRemove.Select(c => c.Key)); }
public void Uninstall(UninstallInfo uninstallInfo) { var toRemove = FindComponentsToRemove(uninstallInfo.GetPublicKeyToken()); Console.WriteLine("Components to remove:"); toRemove.ForEach(Console.WriteLine); Console.WriteLine(); var steps = new List<IUninstallStep> { new RemoveFiles(), new RemoveStartMenuEntry(uninstallInfo), new RemoveRegistryKeys(_registry, uninstallInfo), new RemoveUninstallEntry(uninstallInfo) }; steps.ForEach(s => s.Prepare(toRemove)); steps.ForEach(s => s.PrintDebugInformation()); steps.ForEach(s => s.Execute()); steps.ForEach(s => s.Dispose()); }
public void Uninstall(UninstallInfo uninstallInfo) { var toRemove = FindComponentsToRemove(uninstallInfo.GetPublicKeyToken()); Console.WriteLine("Components to remove:"); toRemove.ForEach(Console.WriteLine); Console.WriteLine(); var steps = new List <IUninstallStep> { new RemoveFiles(), new RemoveStartMenuEntry(uninstallInfo), new RemoveRegistryKeys(_registry, uninstallInfo), new RemoveUninstallEntry(uninstallInfo) }; steps.ForEach(s => s.Prepare(toRemove)); steps.ForEach(s => s.PrintDebugInformation()); steps.ForEach(s => s.Execute()); steps.ForEach(s => s.Dispose()); }
public RemoveStartMenuEntry(UninstallInfo uninstallInfo) { _uninstallInfo = uninstallInfo; }
public RemoveUninstallEntry(UninstallInfo uninstallInfo) { _uninstallInfo = uninstallInfo; }
public RemoveRegistryKeys(ClickOnceRegistry registry, UninstallInfo uninstallInfo) { _registry = registry; _uninstallInfo = uninstallInfo; }
public RemovePin(UninstallInfo uninstallInfo) { _uninstallInfo = uninstallInfo; }
public RemoveStartMenuEntry(UninstallInfo uninstallInfo, bool deepScan) { _uninstallInfo = uninstallInfo; _deepScan = deepScan; }
public RemoveStartMenuEntry(UninstallInfo uninstallInfo) : this(uninstallInfo, true) { }