async static void SquirrellUpdate() { using (var mgr = new UpdateManager(@"C:\DHT\TsunamiLocal\GUI_WPF\bin\x64")) { await mgr.UpdateApp(); } }
private static async Task Update() { try { using (var mgr = new UpdateManager("http://lunyx.net/CasualMeter")) { Logger.Info("Checking for updates."); if (mgr.IsInstalledApp) { Logger.Info($"Current Version: v{mgr.CurrentlyInstalledVersion()}"); var updates = await mgr.CheckForUpdate(); if (updates.ReleasesToApply.Any()) { Logger.Info("Updates found. Applying updates."); var release = await mgr.UpdateApp(); MessageBox.Show(CleanReleaseNotes(release.GetReleaseNotes(Path.Combine(mgr.RootAppDirectory, "packages"))), $"Casual Meter Update - v{release.Version}"); Logger.Info("Updates applied. Restarting app."); UpdateManager.RestartApp(); } } } } catch (Exception e) { //log exception and move on HandleException(e); } }
/// <summary> /// Squirrel check and update. /// </summary> private async Task CheckAndUpdate(bool checkOnly = false) { // 6/27/15 - Task.Wait always times out. Seems to be an issue with the return of Squirrel's async methods. try { AddMessage("Start of CheckAndUpdate"); using (var updateManager = new UpdateManager(Program.PackageUrl, Program.PackageId)) { // Check AddMessage(String.Format("UpdateManager: {0}", JsonConvert.SerializeObject(updateManager, Formatting.Indented))); AddMessage("Calling UpdateManager.CheckForUpdate"); var updateInfo = await updateManager.CheckForUpdate(); AddMessage(String.Format( "UpdateManager.CheckForUpdate returned UpdateInfo: {0}", JsonConvert.SerializeObject(updateInfo, Formatting.Indented))); if (checkOnly) { return; } // Update if (updateInfo.ReleasesToApply.Count > 0) { AddMessage("Calling UpdateManager.UpdateApp"); var releaseEntry = await updateManager.UpdateApp(); AddMessage(String.Format( "UpdateManager.UpdateApp returned ReleaseEntry: {0}", JsonConvert.SerializeObject(releaseEntry, Formatting.Indented))); } else { AddMessage("No updates to apply"); } } } catch (Exception exception) { Log.Error("Exception in CheckAndUpdate", exception); throw; } }
public async void ProcessStaging() { using (var mgr = new UpdateManager("https://path/to/my/update/folder")) { await mgr.UpdateApp(); } }
public async Task UpgradeRunsSquirrelAwareAppsWithUpgradeFlag() { string tempDir; string remotePkgDir; using (Utility.WithTempDirectory(out tempDir)) using (Utility.WithTempDirectory(out remotePkgDir)) { IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir); var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.FullInstall(false, new ProgressSource()); } await Task.Delay(1000); IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir); pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.UpdateApp(); } await Task.Delay(1000); Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", "args2.txt"))); Assert.True(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", "args.txt"))); var text = File.ReadAllText(Path.Combine(tempDir, "theApp", "app-0.2.0", "args.txt"), Encoding.UTF8); Assert.Contains("updated|0.2.0", text); } }
public App() { InitializeComponent(); AppearanceManager.Current.ThemeSource = AppearanceManager.DarkThemeSource; Task.Factory.StartNew(async () => { AboutViewModel.Instance.State = "Updater process started"; await Task.Delay(TimeSpan.FromSeconds(1)); while (true) { try { AboutViewModel.Instance.State = "Ready for the first check..."; using (var updateManager = new UpdateManager(Releases)) { AboutViewModel.Instance.State = "Updating..."; await updateManager.UpdateApp(); AboutViewModel.Instance.State = "Updated!"; } } catch (Exception x) { AboutViewModel.Instance.State = x.Message; return; } await Task.Delay(TimeSpan.FromHours(1)); } }); }
public ShellViewModel( EndpointsViewModel endpoints, MessageListViewModel messageList, MessageViewerViewModel messageViewer, HeadersViewModel headers) { Version = GetType().Assembly .GetCustomAttributes(false) .OfType<AssemblyInformationalVersionAttribute>() .First() .InformationalVersion; RefreshCommand = ServiceControl.Instance.IsValid.ToCommand(p => DoRefresh()); Anchorables = new IContainerViewModel[] { endpoints, messageList }; Documents = new IContainerViewModel[] { messageViewer, headers }; Task.Run(async () => { using (var mgr = new UpdateManager(@"https://s3.amazonaws.com/serviceinsight/")) { await mgr.UpdateApp(); } }); }
private async void Callback(object state) { Squirrel.UpdateManager manager = null; try { if (_settings.UpdatePreference == UpdatePreference.Developer) { manager = await Squirrel.UpdateManager.GitHubUpdateManager(GithubProjectUrl, null, null, null, true); } else { manager = await Squirrel.UpdateManager.GitHubUpdateManager(GithubProjectUrl); } //workaround since update manager apparently sucks await manager.UpdateApp().ConfigureAwait(false); } catch (Exception e) { _log.FatalException("Failed to update app " + e.Message, e); } finally { if (manager != null) { manager.Dispose(); } } }
private async void CheckForAppUpdates() { using (var updateManager = new UpdateManager(APP_UPDATE_URL, APPLICATION_ID, FrameworkVersion.Net45)) { await updateManager.UpdateApp(); } }
private static ThreadStart UpdateOpenLiveWriter(string downloadUrl, bool checkNow) { return(async() => { if (checkNow) { try { using (var manager = new Squirrel.UpdateManager(downloadUrl)) { var update = await manager.CheckForUpdate(); if (update != null && update.ReleasesToApply.Count > 0 && update.FutureReleaseEntry.Version < update.CurrentlyInstalledVersion.Version) { Trace.WriteLine("Update is older than currently running version, not installing."); Trace.WriteLine($"Current: {update.CurrentlyInstalledVersion.Version} Update: {update.FutureReleaseEntry.Version}"); return; } await manager.UpdateApp(); } } catch (Exception ex) { Trace.WriteLine("Unexpected error while updating Open Live Writer. " + ex); } } }); }
private async void ScheduleApplicationUpdates(Object o) { var location = UpdateHelper.AppUpdateCheckLocation; var appName = Assembly.GetExecutingAssembly().GetName().Name; using (var mgr = new UpdateManager(location, appName, FrameworkVersion.Net45)) { try { UpdateInfo updateInfo = await mgr.CheckForUpdate(); if (updateInfo.FutureReleaseEntry != null) { if (updateInfo.CurrentlyInstalledVersion.Version == updateInfo.FutureReleaseEntry.Version) return; await mgr.UpdateApp(); // This will show a button that will let the user restart the app Dispatcher.Invoke(ShowUpdateIsAvailable); // This will restart the app automatically //Dispatcher.InvokeAsync<Task>(ShutdownApp); } } catch (Exception ex) { var a = ex; } } }
public static async Task <ReleaseEntry> SilentUpdate() { var appName = GetAppName(); var updateLocation = GetUpdateLocation(); using (var mgr = new Squirrel.UpdateManager(updateLocation, appName, Squirrel.FrameworkVersion.Net45)) { return(await mgr.UpdateApp()); } }
private async void toolStripButtonCheckForUpdates_Click(object sender, EventArgs e) { // NB: For this version, always say your app is using .NET 4.5, even if it's // totally not using (var mgr = new UpdateManager(textBoxPathForUpdate.Text)) { var release = await mgr.UpdateApp(); if (release != null) { MessageBox.Show("New App Version Installed " + release.Version + " \n Close and reopen to load new version."); } } }
private static void Main() { Task.Run(async () => { var upgraded = false; while (!upgraded) { await Task.Delay(TimeSpan.FromSeconds(5)); using ( var mgr = new UpdateManager(@"http://distribute.klonmaschine.de/metrothing/", "metrothing", FrameworkVersion.Net45)) { SquirrelAwareApp.HandleEvents( v => mgr.CreateShortcutForThisExe(), v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe()); // Try the update try { var updateInfo = await mgr.CheckForUpdate(); if (updateInfo != null && updateInfo.ReleasesToApply.Count > 0) { #if !DEBUG await mgr.UpdateApp(); #endif upgraded = true; Singleton<InstallationManager>.Instance.Updated( updateInfo.FutureReleaseEntry.Version.ToString(), String.Join("", updateInfo.FetchReleaseNotes().Values)); } } catch (Exception e) { Trace.WriteLine("Squirrel update failed: " + e.Message); } } if (!upgraded) await Task.Delay(TimeSpan.FromHours(12)); } }); MetroThing.Program.Main(); }
private async void ButtonUpdateDo_OnClick(object sender, RoutedEventArgs e) { try { using (var mgr = new UpdateManager(ConfigurationManager.AppSettings["UpdatePath"])) { var release = await mgr.UpdateApp(); this.UpdateDoResult.Text = release.EntryAsString; } } catch (Exception test) { this.UpdateDoResult.Text = "Updated to: " + test.Message; } }
async void bw_DoWork(object sender, DoWorkEventArgs e) { do { try { using (var mgr = new UpdateManager(@"C:\dev\helloworld\HelloWorld\Releases", "HelloWorldSquirrel")) { var updateInfo = await mgr.CheckForUpdate(false, progress => { }); if (updateInfo != null && updateInfo.ReleasesToApply.Count != 0) { await mgr.UpdateApp(); Restart = true; } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } Console.WriteLine("I am running"); Thread.Sleep(2000); } while (true); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { Task.Run(async () => { using (var mgr = new UpdateManager(@"https://s3-eu-west-1.amazonaws.com/squirrelpackager")) { try { await mgr.UpdateApp(); } catch (Exception ex) { MessageBox.Show("From Update Manager : " + Environment.NewLine + ex.InnerException.Message + Environment.NewLine + ex.Message); } } }); }
private void CheckForUpdate(long x) { #if !DEBUG Task.Run(async () => { try { using (var mgr = new UpdateManager(UpdateFolder)) { var release = await mgr.UpdateApp(); if (release.Version > mgr.CurrentlyInstalledVersion()) { OnNewVersionAvailable(release); } } } catch (Exception e) { _logger.Error(e, "Failed checking for updates: {0}", e.Message); _crashManager.Report(e, "squirrel"); } }); #endif }
async void _init() { #if DEBUG == false try { using (var mgr = new UpdateManager(@"https://daybar.blob.core.windows.net/app/install")) { await mgr.UpdateApp(); } } catch { } #endif _deviceService.SetWindowHandle(new WindowInteropHelper(Application.Current.MainWindow).Handle); await Task.Delay(1000); _showLogin(false); }
private static ThreadStart UpdateOpenLiveWriter(string downloadUrl, bool checkNow) { return async () => { if (checkNow) { try { using (var manager = new Squirrel.UpdateManager(downloadUrl)) { await manager.UpdateApp(); } } catch (Exception ex) { Trace.WriteLine("Unexpected error while updating Open Live Writer. " + ex); } } }; }
private static ThreadStart UpdateOpenLiveWriter(string downloadUrl, bool checkNow) { return(async() => { if (checkNow) { try { using (var manager = new Squirrel.UpdateManager(downloadUrl)) { await manager.UpdateApp(); } } catch (Exception ex) { Trace.WriteLine("Unexpected error while updating Open Live Writer. " + ex); } } }); }
internal void Update() { Debug.WriteLine("Updating ..."); #if DEBUG using (var mgr = new UpdateManager(@"c:\lr.m\winR\Releases\")) { #else using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/MarcoMedrano/winR").Result) { #endif var res = mgr.UpdateApp().Result; if (res != null) MessageBox.Show("Updated to " + res.Version, "Done!", MessageBoxButton.OK, MessageBoxImage.Exclamation); else MessageBox.Show("No new versions.", "", MessageBoxButton.OK, MessageBoxImage.Information); } } }
public async Task UpdateApp() { var updatePath = ConfigurationManager.AppSettings["UpdatePathFolder"]; var packageId = ConfigurationManager.AppSettings["PackageID"]; using (var mgr = new UpdateManager(updatePath, packageId, FrameworkVersion.Net45)) { var updates = await mgr.CheckForUpdate(); if (updates.ReleasesToApply.Any()) { var lastVersion = updates.ReleasesToApply.OrderBy(x => x.Version).Last(); await mgr.DownloadReleases(new[] { lastVersion }); await mgr.ApplyReleases(updates); await mgr.UpdateApp(); MessageBox.Show("The application has been updated - please close and restart."); } else { MessageBox.Show("No Updates are available at this time."); } } }
private async Task SquirrelUpdate(bool showInfo) { try { using (UpdateManager _manager = new UpdateManager(ConfigurationManager.AppSettings["CurrentReleaseURL"])) { UpdateInfo _update = await _manager.CheckForUpdate(); if (_update.ReleasesToApply.Any()) { Version _newVersion = _update.ReleasesToApply.OrderByDescending(r => r.Version).First().Version.Version; Update _updateWindow = new Update(); _updateWindow.Show(); await _manager.UpdateApp((p) => _updateWindow.SetProgress(p)); _updateWindow.Close(); string _newExePath = Utilities.Paths.Exe(_newVersion); if (Framework.Settings.Instance.RunAtStartup) { Utilities.Startup.EnableStartupTask(_newExePath); } Process.Start(_newExePath); Shutdown(); } else if (showInfo) { MessageBox.Show(Constants.Generic.UPDATEMSG, Constants.Generic.PROGRAMNAME, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); } } } catch (WebException) { if (showInfo) { MessageBox.Show(Constants.Generic.UPDATEERROR, Constants.Generic.UPDATEERRORTITLE, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); } } }
public static async Task<ReleaseEntry> SilentUpdate() { var appName = GetAppName(); var updateLocation = GetUpdateLocation(); using (var mgr = new Squirrel.UpdateManager(updateLocation, appName, Squirrel.FrameworkVersion.Net45)) { return await mgr.UpdateApp(); } }
/// <summary> /// Update the program /// </summary> /// <returns></returns> private async Task Squirrel_UpdateAppAsync(bool showMessages = false) { Debug.WriteLine("Checking for updates..."); try { using (var mgr = new UpdateManager("https://s3.amazonaws.com/steamdesktopauthenticator/releases")) { UpdateInfo update = await mgr.CheckForUpdate(); if(update.ReleasesToApply.Count > 0) { await mgr.UpdateApp(); MessageBox.Show("A new version has been installed. Restart to apply.", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (showMessages) { MessageBox.Show("You are using the latest version.", "Updater", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception err) { Debug.WriteLine("Failed"); if (showMessages) { MessageBox.Show(err.ToString(), "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private async Task<string> SquirrelUpdate(bool showInfo) { try { using (UpdateManager _manager = new UpdateManager(ConfigurationManager.AppSettings["CurrentReleaseURL"])) { UpdateInfo _update = await _manager.CheckForUpdate(); if (_update.ReleasesToApply.Any()) { Version _newVersion = _update.ReleasesToApply.OrderByDescending(r => r.Version).First().Version.Version; Update _updateWindow = new Update(); _updateWindow.Show(); await _manager.UpdateApp((p) => _updateWindow.SetProgress(p)); _updateWindow.Close(); return Utilities.Paths.Exe(_newVersion); } else if (showInfo) { MessageBox.Show(Framework.Resources.UpdateSuccessText, Framework.Resources.AppName, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); } } } catch (WebException) { if (showInfo) { MessageBox.Show(Framework.Resources.UpdateErrorText, Framework.Resources.UpdateErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); } } catch (Exception e) { Framework.Settings.Instance.AutoUpdate = false; Framework.Settings.Instance.Save(); using (EventLog _log = new EventLog("Application")) { _log.Source = Framework.Resources.AppName; _log.WriteEntry(e.ToString(), EventLogEntryType.Error, 100, 1); } MessageBox.Show(Framework.Resources.UpdateErrorFatalText, Framework.Resources.UpdateErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly); } return null; }
public async Task FullUninstallRemovesAllVersions() { string tempDir; string remotePkgDir; using (Utility.WithTempDirectory(out tempDir)) using (Utility.WithTempDirectory(out remotePkgDir)) { IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir); var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.FullInstall(false, new ProgressSource()); } await Task.Delay(1000); IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir); pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.UpdateApp(); } await Task.Delay(1000); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.FullUninstall(); } Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.1.0", "args.txt"))); Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", "args.txt"))); Assert.False(Directory.Exists(Path.Combine(tempDir, "theApp"))); } }
public static async void UpdateApp() { string releaseZipFile = Path.GetFileName(_versionInfo?.DownloadReleaseUrl); if (string.IsNullOrEmpty(releaseZipFile)) { Log.Logger.Error($"【wrong download url】:{_versionInfo?.DownloadReleaseUrl}"); return; } _releaseZipFile = Path.Combine(VersionFolder, releaseZipFile); try { using (WebClient webClient = new WebClient()) { Log.Logger.Debug( $"【download release zip file begins】:download {_versionInfo.DownloadReleaseUrl} to {_releaseZipFile}"); webClient.DownloadFile(new Uri(_versionInfo.DownloadReleaseUrl), _releaseZipFile); } if (File.Exists(_releaseZipFile)) { if (Directory.Exists(_releaseFolder)) { Log.Logger.Debug($"【delete folder begins】:{_releaseFolder}"); DirectoryInfo releaseDirectoryInfo = new DirectoryInfo(_releaseFolder); releaseDirectoryInfo.Delete(true); } Log.Logger.Debug($"【create folder begins】:{_releaseFolder}"); Directory.CreateDirectory(_releaseFolder); using (ZipInputStream zipInputStream = new ZipInputStream(File.OpenRead(_releaseZipFile))) { ZipEntry entry; while ((entry = zipInputStream.GetNextEntry()) != null) { string fileName = Path.GetFileName(entry.Name); if (!string.IsNullOrEmpty(fileName)) { string fileItemName = Path.Combine(_releaseFolder, fileName); Log.Logger.Debug($"【unzip file】:upzip {entry.Name} to {fileItemName}"); using (FileStream streamWriter = File.Create(fileItemName)) { byte[] data = new byte[2048]; while (true) { var size = zipInputStream.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } } } } } using ( var updateManager = new Squirrel.UpdateManager(_releaseFolder)) { Log.Logger.Debug( $"【update begins】:..............................................................."); await updateManager.UpdateApp(); Log.Logger.Debug( $"【update ends】:..............................................................."); await Application.Current.Dispatcher.BeginInvoke( new Action(() => { GlobalData.Instance.UpdatingDialog.TbMsg.Text = "升级成功!正在启动新版本。"; Application.Current.Shutdown(); Process newProcess = new Process { StartInfo = { UseShellExecute = true, FileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "ShengtaoSchoolClient.lnk") } }; newProcess.Start(); })); } } else { Log.Logger.Error("【failed to download file】:"); } } catch (Exception ex) { Log.Logger.Error($"【download,unzip,update exception】:{ex}"); await Application.Current.Dispatcher.BeginInvoke( new Action(() => { GlobalData.Instance.UpdatingDialog.TbMsg.Text = $"升级失败!\r\n{ex.Message}"; })); } }
public async Task RunningUpgradeAppTwiceDoesntCrash() { string tempDir; string remotePkgDir; using (Utility.WithTempDirectory(out tempDir)) using (Utility.WithTempDirectory(out remotePkgDir)) { IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir); var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.FullInstall(false, new ProgressSource()); } await Task.Delay(1000); IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir); pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir); ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES")); using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.UpdateApp(); } await Task.Delay(1000); // NB: The 2nd time we won't have any updates to apply. We should just do nothing! using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) { await fixture.UpdateApp(); } await Task.Delay(1000); } }
private async void CheckForUpdates() { using (var mgr = new UpdateManager("http://arkmanager.teamitf.co.uk/iNGen/Releases/", "iNGen")) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe()); try { UpdateInfo updateInfo = await mgr.CheckForUpdate(); if (updateInfo.FutureReleaseEntry != null) { if (updateInfo.CurrentlyInstalledVersion != null) { XElement xelement = XElement.Load("http://arkmanager.teamitf.co.uk/iNGen/version.xml"); StringReader reader = new StringReader(xelement.ToString()); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Models.AppUpdates)); Models.AppUpdates appUpdates = (Models.AppUpdates)xmlSerializer.Deserialize(reader); string changes = MakeChangeLog(appUpdates); if (updateInfo.CurrentlyInstalledVersion.Version == updateInfo.FutureReleaseEntry.Version) return; var updateDialog = new Views.AppUpdate(updateInfo, changes) { Owner = this }; var result = updateDialog.ShowDialog(); if (result == false) return; await mgr.UpdateApp(); var oldPath = System.IO.Path.Combine(mgr.RootAppDirectory, "app-" + updateInfo.CurrentlyInstalledVersion.Version.ToString(), "UserData"); var newPath = System.IO.Path.Combine(mgr.RootAppDirectory, "app-" + updateInfo.FutureReleaseEntry.Version.ToString(), "UserData"); DirectoryInfo d = new DirectoryInfo(oldPath); var files = d.GetFiles(); foreach (var file in files) { file.CopyTo(System.IO.Path.Combine(newPath, file.Name), true); } MessageBox.Show("iNGen Has been Updated. Please Re-Launch It."); Application.Current.Shutdown(0); } else { await mgr.UpdateApp(); MessageBox.Show("iNGen Has been Updated. Please Re-Launch It."); Application.Current.Shutdown(0); } } } catch (Exception ex) { Console.WriteLine("Checking for Updates Failed: " + ex.Message); } } }
static void Main(string[] args) { Console.WriteLine("Starting application..."); var pathToUpdateFolder = @"\\mindelo\KohortClientRelease\" + ConfigurationManager.AppSettings["AppName"]; using (var mgr = new UpdateManager(pathToUpdateFolder)) { var updateInfo = mgr.CheckForUpdate().Result; if (updateInfo.ReleasesToApply.Count > 0) { Console.WriteLine("Updating..."); var result = mgr.UpdateApp().Result; Console.WriteLine("Update complete, press enter to exit and then you can start the application anew!"); Console.ReadLine(); return; } } Console.WriteLine("MyTestApplication has started (version {0}).", Assembly.GetEntryAssembly().GetName().Version); Console.WriteLine(); Console.WriteLine("My sample app setting key has currently \"{0}\" as value.", ConfigurationManager.AppSettings["MySampleSetting"]); Console.WriteLine(); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); }