public bool UpdatePlugin(string name) { setupService.Repositories.UpdateAllRepositories(new ProgressStatus()); Addin addin = AddinManager.Registry.GetAddins().SingleOrDefault(p => p.Description.LocalId.Equals(name, StringComparison.OrdinalIgnoreCase)); if (addin == null) { Logger.Error("The plugin {0} is not installed!", name); return(false); } AddinRepositoryEntry[] entries = setupService.Repositories.GetAvailableAddinUpdates(addin.LocalId, RepositorySearchFlags.LatestVersionsOnly); if (entries.Any()) { var entry = entries.First(); var property = entry.Addin.Properties.SingleOrDefault(p => p.Name.Equals("sharpstar", StringComparison.OrdinalIgnoreCase)); if (property != null) { Version ver = Assembly.GetEntryAssembly().GetName().Version; string verStr = String.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); if (Addin.CompareVersions(verStr, property.Value) <= 0) { Logger.Info("Plugin {0} is now updating to version {1}!", addin.Description.LocalId, entry.Addin.Version); setupService.Install(new ProgressStatus(), entries); AddinManager.Registry.EnableAddin(entry.Addin.Id); AddinManager.Registry.Update(); } else { Logger.Error("Plugin {0} now requires SharpStar version {1}+. Update failed!", addin.Description.LocalId, property.Value); } return(true); } else { Logger.Error("Plugin {0} does not define a minimum SharpStar version requirement. Update failed!", addin.Description.LocalId); } } return(false); }
protected virtual void OnButtonOKClick(object sender, System.EventArgs e) { if (addins_not_found) { err_message = Catalog.GetString("Some of the required add-ins were not found"); Respond(Gtk.ResponseType.Ok); } else { progress_bar.Visible = true; err_message = null; progress_bar.Show(); progress_bar.Fraction = 0; progress_bar.Text = ""; bool res = setup.Install(this, entries); if (!res) { button_cancel.Sensitive = button_ok.Sensitive = false; if (err_message == null) { Catalog.GetString("Installation failed"); } } } Respond(Gtk.ResponseType.Ok); }
protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { if (addinsNotFound) { errMessage = Catalog.GetString("Some of the required add-ins were not found"); Respond(Gtk.ResponseType.Ok); } else { errMessage = null; progressBar.Show(); progressBar.Fraction = 0; progressBar.Text = ""; bool res = setup.Install(this, entries); if (!res) { buttonCancel.Sensitive = buttonOk.Sensitive = false; if (errMessage == null) { errMessage = Catalog.GetString("Installation failed"); } Services.ShowError(null, errMessage, this, true); } } Respond(Gtk.ResponseType.Ok); }
void RunInstall() { try { if (filesToInstall != null) { service.Install(installMonitor, filesToInstall); } else { service.Install(installMonitor, packagesToInstall); } } catch (Exception ex) { installMonitor.Errors.Add(ex.Message); } finally { installMonitor.Dispose(); } }
void RunInstall() { try { service.Install(installMonitor, packagesToInstall); } catch { // Nothing } finally { installMonitor.Dispose(); } }
public void UpgradeCoreAddin() { InitRepository(); CreateTestPackage("10.3"); CreateTestPackage("10.4"); ExtensionNodeList list = AddinManager.GetExtensionNodes("/SimpleApp/InstallUninstallTest"); Assert.AreEqual(1, list.Count); Assert.AreEqual("10.2", ((ItemSetNode)list[0]).Label); Addin adn = AddinManager.Registry.GetAddin("SimpleApp.AddRemoveTest,10.2"); Assert.IsTrue(adn.Enabled); Assert.IsFalse(adn.Description.CanUninstall); // Core add-in can't be uninstalled setup.Repositories.RegisterRepository(monitor, repoUrl, true); var pkg = setup.Repositories.GetAvailableAddinUpdates("SimpleApp.AddRemoveTest", RepositorySearchFlags.LatestVersionsOnly).FirstOrDefault(); Assert.IsNotNull(pkg); Assert.AreEqual("SimpleApp.AddRemoveTest,10.4", pkg.Addin.Id); // Install the add-in setup.Install(new ConsoleProgressStatus(true), pkg); adn = AddinManager.Registry.GetAddin("SimpleApp.AddRemoveTest,10.2"); Assert.IsFalse(adn.Enabled); list = AddinManager.GetExtensionNodes("/SimpleApp/InstallUninstallTest"); Assert.AreEqual(1, list.Count); Assert.AreEqual("10.4", ((ItemSetNode)list[0]).Label); adn = AddinManager.Registry.GetAddin("SimpleApp.AddRemoveTest"); Assert.IsTrue(adn.Enabled); Assert.IsTrue(adn.Description.CanUninstall); // Uninstall the add-in setup.Uninstall(new ConsoleProgressStatus(true), "SimpleApp.AddRemoveTest,10.4"); list = AddinManager.GetExtensionNodes("/SimpleApp/InstallUninstallTest"); Assert.AreEqual(0, list.Count); adn = AddinManager.Registry.GetAddin("SimpleApp.AddRemoveTest"); Assert.IsFalse(adn.Enabled); adn.Enabled = true; list = AddinManager.GetExtensionNodes("/SimpleApp/InstallUninstallTest"); Assert.AreEqual(1, list.Count); Assert.AreEqual("10.2", ((ItemSetNode)list[0]).Label); }
protected virtual bool InstallPlugin(AddinRepositoryEntry[] entries) { if (entries.Length > 0) { var entry = entries.First(); var property = entry.Addin.Properties.SingleOrDefault(p => p.Name.Equals("star", StringComparison.OrdinalIgnoreCase)); if (property != null) { string verStr = string.Format("{0}.{1}.{2}.{3}", StarVersion.Major, StarVersion.Minor, StarVersion.Build, StarVersion.Revision); if (Addin.CompareVersions(verStr, property.Value) <= 0) { Logger.Info("Plugin {0} is now updating to version {1}!", entry.Addin.Name, entry.Addin.Version); SetupService.Install(null, entries); AddinManager.Registry.EnableAddin(entry.Addin.Id); AddinManager.Registry.Update(); } else { Logger.Error("Plugin {0} now requires Star version {1}+. Update failed!", entry.Addin.Name, property.Value); } return(true); } else { Logger.Error("Plugin {0} does not define a minimum Star version requirement. Update failed!", entry.Addin.Name); } } return(false); }