本文整理汇总了C#中Squirrel.UpdateManager.CurrentlyInstalledVersion方法的典型用法代码示例。如果您正苦于以下问题:C# UpdateManager.CurrentlyInstalledVersion方法的具体用法?C# UpdateManager.CurrentlyInstalledVersion怎么用?C# UpdateManager.CurrentlyInstalledVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Squirrel.UpdateManager
的用法示例。
在下文中一共展示了UpdateManager.CurrentlyInstalledVersion方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
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);
}
}
示例2: InteractiveModule
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;
};
}
示例3: CheckForUpdate
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
}
示例4: GetCurrentlyInstalledVersion
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;
}
}
示例5: CurrentlyInstalledVersionTests
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));
}
}
示例6: SquirrelUpdate
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);
}
}
示例7: MainForm_Shown
/// <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;
}
}