public CreateUninstallerRegistryEntry ( ) : Task |
||
return | Task |
public async Task CallingMethodTwiceShouldUpdateInstaller() { string remotePkgPath; string path; using (Utility.WithTempDirectory(out path)) { using (Utility.WithTempDirectory(out remotePkgPath)) using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) { IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath); await mgr.FullInstall(); } using (var mgr = new UpdateManager("http://lol", "theApp", path)) { await mgr.CreateUninstallerRegistryEntry(); var regKey = await mgr.CreateUninstallerRegistryEntry(); Assert.False(String.IsNullOrWhiteSpace((string)regKey.GetValue("DisplayName"))); mgr.RemoveUninstallerRegistryEntry(); } // NB: Squirrel-Aware first-run might still be running, slow // our roll before blowing away the temp path Thread.Sleep(1000); } var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) .OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall"); using (key) { Assert.False(key.GetSubKeyNames().Contains("theApp")); } }
private static async void InitialInstall(Squirrel.UpdateManager mgr) { mgr.CreateShortcutForThisExe(); await mgr.CreateUninstallerRegistryEntry(); await mgr.FullInstall(); SetAssociation(".wpost", "OPEN_LIVE_WRITER", Application.ExecutablePath, "Open Live Writer post"); }
/// <summary> /// Execute when app is updating /// </summary> /// <param name="version"><see cref="Version"/> version</param> private static void OnAppUpdate(Version version) { using (var manager = new UpdateManager(Constants.UpdateServerUrl)) { manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.Desktop, true); manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.StartMenu, true); manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.AppRoot, true); manager.RemoveUninstallerRegistryEntry(); manager.CreateUninstallerRegistryEntry(); } }
private static void onInitialInstall(Version version) { try { using (var mgr = new Squirrel.UpdateManager(null, "OutlookGoogleCalendarSync")) { log.Info("Creating shortcuts."); mgr.CreateShortcutsForExecutable(Path.GetFileName(System.Windows.Forms.Application.ExecutablePath), Squirrel.ShortcutLocation.Desktop | Squirrel.ShortcutLocation.StartMenu, false); log.Debug("Creating uninstaller registry keys."); mgr.CreateUninstallerRegistryEntry().Wait(); } } catch (System.Exception ex) { log.Error("Problem encountered on initiall install."); OGCSexception.Analyse(ex, true); } onFirstRun(); }
public async Task Update(string updateUrl, string appName = null) { appName = appName ?? getAppNameFromDirectory(); this.Log().Info("Starting update, downloading from " + updateUrl); using (var mgr = new UpdateManager(updateUrl, appName)) { bool ignoreDeltaUpdates = false; this.Log().Info("About to update to: " + mgr.RootAppDirectory); retry: try { var updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3)); await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3)); await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3)); } catch (Exception ex) { if (ignoreDeltaUpdates) { this.Log().ErrorException("Really couldn't apply updates!", ex); throw; } this.Log().WarnException("Failed to apply updates, falling back to full updates", ex); ignoreDeltaUpdates = true; goto retry; } var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe"); await this.ErrorIfThrows(() => mgr.CreateUninstallerRegistryEntry(), "Failed to create uninstaller registry entry"); } }
public async Task Install(bool silentInstall, ProgressSource progressSource, string sourceDirectory = null) { sourceDirectory = sourceDirectory ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var releasesPath = Path.Combine(sourceDirectory, "RELEASES"); this.Log().Info("Starting install, writing to {0}", sourceDirectory); if (!File.Exists(releasesPath)) { this.Log().Info("RELEASES doesn't exist, creating it at " + releasesPath); var nupkgs = (new DirectoryInfo(sourceDirectory)).GetFiles() .Where(x => x.Name.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase)) .Select(x => ReleaseEntry.GenerateFromFile(x.FullName)); ReleaseEntry.WriteReleaseFile(nupkgs, releasesPath); } var ourAppName = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasesPath, Encoding.UTF8)) .First().PackageName; using (var mgr = new UpdateManager(sourceDirectory, ourAppName)) { this.Log().Info("About to install to: " + mgr.RootAppDirectory); if (Directory.Exists(mgr.RootAppDirectory)) { this.Log().Warn("Install path {0} already exists, burning it to the ground", mgr.RootAppDirectory); await this.ErrorIfThrows(() => Utility.DeleteDirectory(mgr.RootAppDirectory), "Failed to remove existing directory on full install, is the app still running???"); this.ErrorIfThrows(() => Utility.Retry(() => Directory.CreateDirectory(mgr.RootAppDirectory), 3), "Couldn't recreate app directory, perhaps Antivirus is blocking it"); } Directory.CreateDirectory(mgr.RootAppDirectory); var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe"); this.ErrorIfThrows(() => File.Copy(Assembly.GetExecutingAssembly().Location, updateTarget, true), "Failed to copy Update.exe to " + updateTarget); await mgr.FullInstall(silentInstall, progressSource.Raise); await this.ErrorIfThrows(() => mgr.CreateUninstallerRegistryEntry(), "Failed to create uninstaller registry entry"); } }
public async Task Install(bool silentInstall, string sourceDirectory = null) { sourceDirectory = sourceDirectory ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var releasesPath = Path.Combine(sourceDirectory, "RELEASES"); this.Log().Info("Starting install, writing to {0}", sourceDirectory); if (!File.Exists(releasesPath)) { this.Log().Info("RELEASES doesn't exist, creating it at " + releasesPath); var nupkgs = (new DirectoryInfo(sourceDirectory)).GetFiles() .Where(x => x.Name.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase)) .Select(x => ReleaseEntry.GenerateFromFile(x.FullName)); ReleaseEntry.WriteReleaseFile(nupkgs, releasesPath); } var ourAppName = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasesPath, Encoding.UTF8)) .First().PackageName; using (var mgr = new UpdateManager(sourceDirectory, ourAppName, FrameworkVersion.Net45)) { Directory.CreateDirectory(mgr.RootAppDirectory); var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe"); this.ErrorIfThrows(() => File.Copy(Assembly.GetExecutingAssembly().Location, updateTarget, true), "Failed to copy Update.exe to " + updateTarget); await mgr.FullInstall(silentInstall); await this.ErrorIfThrows(() => mgr.CreateUninstallerRegistryEntry(), "Failed to create uninstaller registry entry"); } }
private static async Task<bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false) { try { Log.Info($"Checking for updates (ignoreDelta={ignoreDelta})"); splashScreenWindow.StartSkipTimer(); var updateInfo = await mgr.CheckForUpdate(ignoreDelta); if(!updateInfo.ReleasesToApply.Any()) { Log.Info("No new updated available"); return false; } var latest = updateInfo.ReleasesToApply.LastOrDefault()?.Version; var current = mgr.CurrentlyInstalledVersion(); if(latest <= current) { Log.Info($"Installed version ({current}) is greater than latest release found ({latest}). Not downloading updates."); return false; } if(IsRevisionIncrement(current?.Version, latest?.Version)) { Log.Info($"Latest update ({latest}) is revision increment. Updating in background."); splashScreenWindow.SkipUpdate = true; } Log.Info($"Downloading {updateInfo.ReleasesToApply.Count} {(ignoreDelta ? "" : "delta ")}releases, latest={latest?.Version}"); await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating); Log.Info("Applying releases"); await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing); await mgr.CreateUninstallerRegistryEntry(); Log.Info("Done"); return true; } catch(Exception ex) { if(ignoreDelta) return false; if(ex is Win32Exception) Log.Info("Not able to apply deltas, downloading full release"); return await SquirrelUpdate(splashScreenWindow, mgr, true); } }
public async Task Update(string updateUrl, string appName = null) { appName = appName ?? getAppNameFromDirectory(); this.Log().Info("Starting update, downloading from " + updateUrl); // NB: Always basing the rootAppDirectory relative to ours allows us to create Portable // Applications var ourDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ".."); using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45, ourDir)) { bool ignoreDeltaUpdates = false; retry: try { var updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3)); await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3)); await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3)); } catch (Exception ex) { if (ignoreDeltaUpdates) { this.Log().ErrorException("Really couldn't apply updates!", ex); throw; } this.Log().WarnException("Failed to apply updates, falling back to full updates", ex); ignoreDeltaUpdates = true; goto retry; } var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe"); await this.ErrorIfThrows(() => mgr.CreateUninstallerRegistryEntry(), "Failed to create uninstaller registry entry"); } }
/// <summary> /// Execute when app is installing /// </summary> /// <param name="version"><see cref="Version"/> version</param> private static void OnInitialInstall(Version version) { using (var manager = new UpdateManager(Constants.UpdateServerUrl)) { manager.CreateShortcutForThisExe(); manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.Desktop, false); manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.StartMenu, false); manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.AppRoot, false); manager.CreateUninstallerRegistryEntry(); } }
public static void InstallEvent() { var exePath = Assembly.GetEntryAssembly().Location; var appName = Path.GetFileName(exePath); using (var mgr = new UpdateManager(@"https://releases.noelpush.com/", "NoelPush")) { mgr.CreateShortcutsForExecutable(appName, ShortcutLocation.StartMenu | ShortcutLocation.Startup, false); mgr.CreateUninstallerRegistryEntry(); mgr.Dispose(); } }