private IObservable <UpdateAvailableNotification> CheckForUpdates() { return(Observable.Create <UpdateAvailableNotification>(async obs => { string updateUrl = AppModel.GetRegistrySetting("UpdateUrl"); Log.DebugFormat("UpdateUrl = {0}", updateUrl); using (var updateManager = new UpdateManager(updateUrl ?? @"http://bradleygrainger.com/GitBlame/download", "GitBlame", FrameworkVersion.Net45)) { try { UpdateInfo updateInfo = await updateManager.CheckForUpdate(); var releases = updateInfo == null ? new List <ReleaseEntry>() : updateInfo.ReleasesToApply.ToList(); if (updateInfo == null) { Log.Info("CheckForUpdate returned (null)"); } else { Log.InfoFormat("CheckForUpdate: Current=({0}), Future=({1}), {2} ReleasesToApply", ToLog(updateInfo.CurrentlyInstalledVersion), ToLog(updateInfo.FutureReleaseEntry), releases.Count); } if (releases.Count != 0) { await updateManager.DownloadReleases(releases); Log.Info("Downloaded releases"); var newDirectory = await updateManager.ApplyReleases(updateInfo); Log.InfoFormat("ApplyReleases: {0}", newDirectory); if (!string.IsNullOrEmpty(newDirectory)) { var newPath = Path.Combine(newDirectory, "GitBlame.exe"); VisualStudioIntegration.ReintegrateWithVisualStudio(newPath); obs.OnNext(new UpdateAvailableNotification(newPath)); } } } catch (TimeoutException ex) { // Failed to check for updates; try again the next time the app is run Log.ErrorFormat("CheckForUpdates timed out: {0}", ex, ex.Message); } catch (Exception ex) { // Squirrel throws a new Exception in many failure scenarios Log.ErrorFormat("CheckForUpdates failed: {0}", ex, ex.Message); if (ex.InnerException != null) { Log.ErrorFormat("CheckForUpdates inner exception: {0}", ex.InnerException, ex.InnerException.Message); } } } obs.OnCompleted(); })); }
private static IReadOnlyDictionary <string, VisualStudioIntegrationStatus> GetCurrentIntegrationStatus() { var integrationStatus = new Dictionary <string, VisualStudioIntegrationStatus>(); foreach (var integration in (AppModel.GetRegistrySetting("VisualStudioIntegration") ?? "").Split(';').Where(x => x.Length > 1)) { string version = integration.Substring(1); if ((integration[0] == '-' || integration[0] == '+') && s_knownVisualStudioVersions.Contains(version)) { integrationStatus[version] = integration[0] == '-' ? VisualStudioIntegrationStatus.NotInstalled : VisualStudioIntegrationStatus.Installed; } } return(integrationStatus); }