本文整理汇总了C#中Squirrel.UpdateManager类的典型用法代码示例。如果您正苦于以下问题:C# UpdateManager类的具体用法?C# UpdateManager怎么用?C# UpdateManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UpdateManager类属于Squirrel命名空间,在下文中一共展示了UpdateManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
private static async void Update(Task<string> result)
{
if (result.Result == null || result.Result != "1")
return;
try
{
using (var mgr = new UpdateManager(@"https://releases.noelpush.com/", "NoelPush"))
{
var updates = await mgr.CheckForUpdate();
if (updates.ReleasesToApply.Any())
{
var lastVersion = updates.ReleasesToApply.OrderBy(x => x.Version).Last();
await mgr.DownloadReleases(updates.ReleasesToApply);
await mgr.ApplyReleases(updates);
var latestExe = Path.Combine(mgr.RootAppDirectory, string.Concat("app-", lastVersion.Version), "NoelPush.exe");
mgr.Dispose();
RestartAppEvent();
UpdateManager.RestartApp(latestExe);
}
mgr.Dispose();
}
}
catch (Exception e)
{
LogManager.GetCurrentClassLogger().Error(e.Message);
}
}
示例2: CheckForAppUpdates
private async void CheckForAppUpdates()
{
using (var updateManager = new UpdateManager(APP_UPDATE_URL, APPLICATION_ID, FrameworkVersion.Net45))
{
await updateManager.UpdateApp();
}
}
示例3: UpgradeRunsSquirrelAwareAppsWithUpgradeFlag
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);
}
}
示例4: ScheduleApplicationUpdates
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;
}
}
}
示例5: ProcessStaging
public async void ProcessStaging()
{
using (var mgr = new UpdateManager("https://path/to/my/update/folder"))
{
await mgr.UpdateApp();
}
}
示例6: SquirrellUpdate
async static void SquirrellUpdate()
{
using (var mgr = new UpdateManager(@"C:\DHT\TsunamiLocal\GUI_WPF\bin\x64"))
{
await mgr.UpdateApp();
}
}
示例7: App_OnStartup
private void App_OnStartup(object sender, StartupEventArgs e)
{
if (e.Args.Length > 0)
{
using (var mgr = new UpdateManager("http://zizit.lt"))
{
// Note, in most of these scenarios, the app exits after this method
// completes!
SquirrelAwareApp.HandleEvents(
onInitialInstall: v =>
{
mgr.CreateShortcutForThisExe();
Shutdown();
},
onAppUpdate: v =>
{
mgr.CreateShortcutForThisExe();
Shutdown();
},
onAppUninstall: v =>
{
mgr.RemoveShortcutForThisExe();
Shutdown();
},
onFirstRun: () =>
{
MessageBox.Show("Success", "Installation successful", MessageBoxButton.OK);
Shutdown();
});
}
}
}
示例8: 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);
}
}
示例9: App
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));
}
});
}
示例10: CheckAndUpdate
/// <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;
}
}
示例11: InitialInstallSmokeTest
public async Task InitialInstallSmokeTest()
{
string tempDir;
using (Utility.WithTempDirectory(out tempDir)) {
var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages"));
var localAppDir = Path.Combine(tempDir, "theApp");
new[] {
"Squirrel.Core.1.0.0.0-full.nupkg",
}.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(remotePackageDir.FullName, x)));
using (var fixture = new UpdateManager(remotePackageDir.FullName, "theApp", FrameworkVersion.Net45, tempDir)) {
await fixture.FullInstall();
}
var releasePath = Path.Combine(localAppDir, "packages", "RELEASES");
File.Exists(releasePath).ShouldBeTrue();
var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8));
entries.Count().ShouldEqual(1);
new[] {
"ReactiveUI.dll",
"NSync.Core.dll",
}.ForEach(x => File.Exists(Path.Combine(localAppDir, "app-1.0.0.0", x)).ShouldBeTrue());
}
}
示例12: CallingMethodTwiceShouldUpdateInstaller
public async Task CallingMethodTwiceShouldUpdateInstaller()
{
string remotePkgPath;
string path;
using (Utility.WithTempDirectory(out path)) {
using (Utility.WithTempDirectory(out remotePkgPath))
using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
await mgr.FullInstall();
}
using (var mgr = new UpdateManager("http://lol", "theApp", path)) {
await mgr.CreateUninstallerRegistryEntry();
var regKey = await mgr.CreateUninstallerRegistryEntry();
Assert.False(String.IsNullOrWhiteSpace((string)regKey.GetValue("DisplayName")));
mgr.RemoveUninstallerRegistryEntry();
}
// NB: Squirrel-Aware first-run might still be running, slow
// our roll before blowing away the temp path
Thread.Sleep(1000);
}
var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
using (key) {
Assert.False(key.GetSubKeyNames().Contains("theApp"));
}
}
示例13: CleanInstallRunsSquirrelAwareAppsWithInstallFlag
public async Task CleanInstallRunsSquirrelAwareAppsWithInstallFlag()
{
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());
// NB: We execute the Squirrel-aware apps, so we need to give
// them a minute to settle or else the using statement will
// try to blow away a running process
await Task.Delay(1000);
Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.1.0", "args2.txt")));
Assert.True(File.Exists(Path.Combine(tempDir, "theApp", "app-0.1.0", "args.txt")));
var text = File.ReadAllText(Path.Combine(tempDir, "theApp", "app-0.1.0", "args.txt"), Encoding.UTF8);
Assert.Contains("firstrun", text);
}
}
}
示例14: ShellViewModel
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();
}
});
}
示例15: App
/// <summary>
/// Initializes a new instance of the App class.
/// </summary>
static App()
{
Logger.Info(
"Popcorn starting...");
var watchStart = Stopwatch.StartNew();
AppDomain.CurrentDomain.ProcessExit += (sender, args) => UpdateManager.Dispose();
Directory.CreateDirectory(Helpers.Constants.Logging);
DispatcherHelper.Initialize();
LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
UpdateManager = new UpdateManager(Helpers.Constants.UpdateServerUrl, Helpers.Constants.ApplicationName);
watchStart.Stop();
var elapsedStartMs = watchStart.ElapsedMilliseconds;
Logger.Info(
$"Popcorn started in {elapsedStartMs} milliseconds.");
Task.Run(async () =>
{
await StartUpdateProcessAsync();
});
}