public PluginDeletions PrepareUninstallPlugins(List <XtbPlugin> pluginsTodelete) { var pds = new PluginDeletions { PreviousProcessId = Process.GetCurrentProcess().Id }; // Get list of files to delete foreach (var plugin in pluginsTodelete) { var conflicts = XrmToolBoxPlugins.Plugins.Where(p => p.Id != plugin.Id && (p.Action == PackageInstallAction.None || p.Action == PackageInstallAction.Update) && plugin.Files.Any(ff => p.Files.Contains(ff))).ToList(); if (conflicts.Any()) { var conflictedFiles = conflicts.SelectMany(c => c.Files).Select(f => f); pds.Plugins.Add(new PluginDeletion { Conflict = true, Files = plugin.Files.Where(f => !conflictedFiles.Contains(f)).Select(f => Path.GetFileName(f)).ToList() }); } else { pds.Plugins.Add(new PluginDeletion { Files = plugin.Files.Select(f => Path.GetFileName(f)).ToList() }); } } return(pds); }
public PluginDeletions PrepareUninstallPlugins(List <XtbNuGetPackage> packages) { var pds = new PluginDeletions { PreviousProcessId = Process.GetCurrentProcess().Id }; // Get list of files to delete var packagesToDelete = new Dictionary <XtbNuGetPackage, List <string> >(); foreach (var p in packages) { var files = p.Package.GetFiles(); packagesToDelete.Add(p, files.Select(f => f.EffectivePath).ToList()); } foreach (var package in packagesToDelete) { var conflicts = Packages.Where(p => !packagesToDelete.ContainsKey(p) && (p.Action == PackageInstallAction.None || p.Action == PackageInstallAction.Update) && p.Package.GetFiles().Any(ff => package.Value.Contains(ff.EffectivePath))).ToList(); if (conflicts.Any()) { var conflictedFiles = conflicts.SelectMany(c => c.Package.GetFiles()).Select(f => f.EffectivePath); pds.Plugins.Add(new PluginDeletion { Conflict = true, Files = package.Value.Where(f => !conflictedFiles.Contains(f)).ToList() }); } else { pds.Plugins.Add(new PluginDeletion { Files = package.Value, }); } } return(pds); }
public void PerformUninstallation(PluginDeletions deletions) { string filePath = Path.Combine(Paths.XrmToolBoxPath, "Deletion.xml"); if (File.Exists(filePath)) { using (StreamReader reader = new StreamReader(filePath)) { var existingPds = (PluginDeletions)XmlSerializerHelper.Deserialize(reader.ReadToEnd(), typeof(PluginDeletions)); deletions.Plugins.AddRange(existingPds.Plugins); } } XmlSerializerHelper.SerializeToFile(deletions, filePath); if (DialogResult.Yes == MessageBox.Show( "This application needs to restart to remove tools. Click Yes to restart this application now", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { Application.Restart(); } }