private async System.Threading.Tasks.Task UpdateApplicationAsync() { // only check for updates if there were no command-line arguments and debugger not attached if (Debugger.IsAttached || SettingsService.DisableUpdates) { return; } using (var updateManager = await UpdateManager.GitHubUpdateManager("https://github.com/KirillOsenkov/MSBuildStructuredLog")) { var result = await updateManager.UpdateApp(); var currentVersion = updateManager.CurrentlyInstalledVersion(); string message; if (result == null || result.Version == currentVersion) { message = "You have the latest version: " + currentVersion.ToString(); FileAssociations.EnsureAssociationsSet(); } else if (result.Version > currentVersion) { message = "After restarting the app you will be on version " + result.Version.ToString(); } else { message = $"You're running a version ({currentVersion.ToString()}) which is newer than the latest stable ({result.Version})."; } var welcomeScreen = mainContent.Content as WelcomeScreen; if (welcomeScreen != null) { welcomeScreen.Version = message; } } }
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { try { var args = Environment.GetCommandLineArgs(); if (args.Length > 1 && HandleArguments(args)) { return; } if (TryOpenFromClipboard()) { return; } DisplayWelcomeScreen(); // only check for updates if there were no command-line arguments and debugger not attached if (Debugger.IsAttached || SettingsService.DisableUpdates) { return; } using (var updateManager = await UpdateManager.GitHubUpdateManager("https://github.com/KirillOsenkov/MSBuildStructuredLog")) { var result = await updateManager.UpdateApp(); var currentVersion = updateManager.CurrentlyInstalledVersion(); string message; if (result == null || result.Version == currentVersion) { message = "You have the latest version: " + currentVersion.ToString(); FileAssociations.EnsureAssociationsSet(); } else if (result.Version > currentVersion) { message = "After restarting the app you will be on version " + result.Version.ToString(); } else { message = $"You're running a version ({currentVersion.ToString()}) which is newer than the latest stable ({result.Version})."; } var welcomeScreen = mainContent.Content as WelcomeScreen; if (welcomeScreen != null) { welcomeScreen.Version = message; } } } catch (Exception ex) { var welcomeScreen = mainContent.Content as WelcomeScreen; if (welcomeScreen != null) { var text = ex.ToString(); if (text.Contains("Update.exe not found")) { text = "Update.exe not found; app will not update."; } welcomeScreen.Message = text; } } }