CurrentlyInstalledVersion() public method

public CurrentlyInstalledVersion ( string executable = null ) : SemanticVersion
executable string
return SemanticVersion
Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public InteractiveModule(HostControl hostControl)
        {
            StaticConfiguration.DisableErrorTraces = false;

            Get["/version"] = _ =>
            {
                var updateManager = new UpdateManager(null);
                return Response.AsJson(updateManager.CurrentlyInstalledVersion()?.ToString());
            };

            Post["/stop"] = _ =>
            {
                Task.Run(() => hostControl.Stop());
                return HttpStatusCode.OK;
            };
        }
Ejemplo n.º 3
0
 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
 }
Ejemplo n.º 4
0
        public static Version GetCurrentlyInstalledVersion()
        {
            bool isDebug   = false;
            var  updateUrl = GetUpdateLocation();

#if DEBUG
            isDebug = true;
            //updateURL = Properties.Settings.Default.LocalUpdateURL;
#endif

            if (isDebug)
            {
                return(new Version(0, 0, 0, 0));
            }

            using (var mgr = new Squirrel.UpdateManager(updateUrl, Properties.Settings.Default.ApplicationName, Squirrel.FrameworkVersion.Net45))
            {
                var version = mgr.CurrentlyInstalledVersion();
                return(version);
            }
        }
Ejemplo n.º 5
0
        public static Version GetCurrentlyInstalledVersion()
        {
            bool isDebug = false;
            var updateUrl = GetUpdateLocation();

#if DEBUG
            isDebug = true;
            //updateURL = Properties.Settings.Default.LocalUpdateURL;
#endif

            if (isDebug)
            {
                return new Version(0, 0, 0, 0);
            }

            using (var mgr = new Squirrel.UpdateManager(updateUrl, Properties.Settings.Default.ApplicationName, Squirrel.FrameworkVersion.Net45))
            {
                var version = mgr.CurrentlyInstalledVersion();
                return version;
            }

        }
Ejemplo n.º 6
0
            public void CurrentlyInstalledVersionTests(string input, string expectedVersion)
            {
                input = Environment.ExpandEnvironmentVariables(input);
                var expected = expectedVersion != null ? new SemanticVersion(expectedVersion) : default(SemanticVersion);

                using (var fixture = new UpdateManager("http://lol", "theApp")) {
                    Assert.Equal(expected, fixture.CurrentlyInstalledVersion(input));
                }
            }
		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);
			}
		}
Ejemplo n.º 8
0
        /// <summary>
        /// Handles the Shown event of the MainForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private async void MainForm_Shown(object sender, EventArgs e)
        {
            string updateUrl = @"http://journaley.s3.amazonaws.com/stable";

            string updateSrcFile = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                "UpdateSource");

            if (File.Exists(updateSrcFile))
            {
                updateUrl = File.ReadAllText(updateSrcFile, System.Text.Encoding.UTF8).Trim();
            }

            // Update Check
            ++this.UpdateProcessCount;

            try
            {
                using (var mgr = new UpdateManager(updateUrl))
                {
                    // Disable update check when in develop mode.
                    if (!mgr.IsInstalledApp)
                    {
                        return;
                    }

                    this.CurrentlyInstalledVersion = mgr.CurrentlyInstalledVersion();

                    var updateInfo = await mgr.CheckForUpdate();

                    if (updateInfo == null)
                    {
                        return;
                    }

                    if (updateInfo.ReleasesToApply.Any())
                    {
                        await mgr.DownloadReleases(updateInfo.ReleasesToApply);

                        // First, if the user already checked the auto-update option,
                        // simply apply them.
                        if (this.Settings.AutoUpdate)
                        {
                            await mgr.ApplyReleases(updateInfo);
                            return;
                        }

                        // Save the updateInfo and indicate that there is an available update.
                        this.UpdateInfo = updateInfo;
                        this.UpdateAvailable = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
                Logger.Log(ex.StackTrace);
            }
            finally
            {
                --this.UpdateProcessCount;
            }
        }