public void CheckVersion() { var updater = new ApplicationUpdater(typeof(MainWindow)); bool result = updater.IsNewVersionAvailable(false); Console.WriteLine("New Version is available: " + result); }
/// <summary> /// アップデートのダウンロード進捗表示ビューモデルを初期化する /// </summary> /// <param name="applicationUpdater">アップデート機能</param> public UpdateDownloadProgressViewModel(ApplicationUpdater applicationUpdater) { _ApplicationUpdater = applicationUpdater; CancelCommand = new ReactiveCommand().WithSubscribe(Cancel); // ダウンロードが終わり次第アプリケーションを終了し、更新を適用する _ = applicationUpdater.UpdateAfterDownloading(); }
/// <summary> /// Initializes a new instance of the <see cref="UpdateInformationForm"/> class. /// </summary> /// <param name="updater">The updater.</param> public UpdateInformationForm(ApplicationUpdater updater) { InitializeComponent(); UpdateInfo latest = updater.UpdateInfoList[updater.UpdateInfoList.GetLatestVersion( )]; this.infoLabel.Text = string.Format(Properties.Strings.UpdatesAvailableMessage, latest.Version.ToString(), updater.UpdateName); this.changeComments.Text = this.removeHtmlFromUpdateMessage(latest.Comments); }
private async void CheckForApplicationUpdate() { var updater = new ApplicationUpdater( "NSwagStudio.msi", GetType().Assembly, "http://rsuter.com/Projects/NSwagStudio/updates.php"); await updater.CheckForUpdate(this); }
private async void CheckForApplicationUpdate() { var updater = new ApplicationUpdater( "ProjectDependencyBrowser.msi", GetType().Assembly, "http://rsuter.com/Projects/ProjectDependencyBrowser/updates.xml"); await updater.CheckForUpdate(this); }
public void DownloadFileWithEvents() { var updater = new ApplicationUpdater(typeof(Program)); updater.DownloadProgressChanged += updater_DownloadProgressChanged; File.Delete(updater.DownloadStoragePath); Assert.IsTrue(updater.Download()); Assert.IsTrue(File.Exists(updater.DownloadStoragePath)); }
public async Task DownloadFile() { var updater = new ApplicationUpdater(typeof(Program)); updater.DownloadProgressChanged += updater_DownloadProgressChanged; File.Delete(updater.DownloadStoragePath); Assert.IsTrue(await updater.DownloadAsync()); Assert.IsTrue(File.Exists(updater.DownloadStoragePath)); }
/// <summary> /// Method to check if there is a new application version available. /// </summary> private async void UpdateAsync() { try { var update = await ApplicationUpdater.CheckForRemoteUpdateAsync().ConfigureAwait(true); if (update.CanUpdate) { var boxType = update.Update.Type == UpdateType.Standard ? BoxType.Default : BoxType.Warning; var boxText = update.Update.Type == UpdateType.Standard ? LocalizationEx.GetUiString("dialog_message_update_standard_text", Thread.CurrentThread.CurrentCulture) : LocalizationEx.GetUiString("dialog_message_update_critical_text", Thread.CurrentThread.CurrentCulture); var boxTitle = update.Update.Type == UpdateType.Standard ? LocalizationEx.GetUiString("dialog_message_update_standard_title", Thread.CurrentThread.CurrentCulture) : LocalizationEx.GetUiString("dialog_message_update_critical_title", Thread.CurrentThread.CurrentCulture); var userResult = _windowManager.ShowMetroMessageBox( string.Format(boxText, update.Update.Version), boxTitle, MessageBoxButton.YesNo, boxType); if (userResult != MessageBoxResult.Yes) { return; } var updateViewModel = new UpdateViewModel(update.Update) { DisplayName = LocalizationEx.GetUiString("window_update_title", Thread.CurrentThread.CurrentCulture) }; dynamic settings = new ExpandoObject(); settings.WindowStartupLocation = WindowStartupLocation.CenterOwner; settings.Owner = GetView(); var result = _windowManager.ShowDialog(updateViewModel, null, settings); if (!result) { return; } if (!File.Exists(updateViewModel.InstallerPath)) { return; } // start the installer Process.Start(updateViewModel.InstallerPath); // kill running application Process.GetCurrentProcess().Kill(); } } catch (Exception) { } }
public async Task CheckForRemoteUpdateTest() { _remoteUpdate = await ApplicationUpdater.CheckForRemoteUpdateAsync().ConfigureAwait(false); Assert.AreNotEqual(_remoteUpdate, null); Assert.AreNotEqual(_remoteUpdate.Update, null); Assert.AreNotEqual(_remoteUpdate.Update.Installer, null); Assert.AreNotEqual(_remoteUpdate.Update.Signature, null); Assert.AreEqual(_remoteUpdate.Update.Publickey, Global.ApplicationUpdatePublicKey); Assert.AreEqual(_remoteUpdate.Update.Installer.Name, "SimpleDNSCrypt.msi"); }
public void DownloadFileAndRun() { var updater = new ApplicationUpdater(typeof(Program)); File.Delete(updater.DownloadStoragePath); Assert.IsTrue(updater.Download()); Assert.IsTrue(File.Exists(updater.DownloadStoragePath)); updater.ExecuteDownloadedFile(); }
/// <summary> /// Download the given signature file. /// </summary> /// <param name="remoteSignature">The signature to download.</param> /// <returns></returns> public async Task DownloadSignatureAsync(Signature remoteSignature) { _signature = await ApplicationUpdater.DownloadRemoteSignatureAsync(remoteSignature.Uri).ConfigureAwait(false); if (!string.IsNullOrEmpty(_signature)) { IsSignatureDownloaded = true; } IsUpdatingSignature = false; }
/// <summary> /// Download the given installer file. /// </summary> /// <param name="remoteInstaller">The installer to download.</param> /// <returns></returns> public async Task DownloadInstallerAsync(Installer remoteInstaller) { _installer = await ApplicationUpdater.DownloadRemoteInstallerAsync(remoteInstaller.Uri).ConfigureAwait(false); if (_installer != null) { IsInstallerDownloaded = true; } IsUpdatingInstaller = false; }
internal static async Task <int> MainAsync(CommandLineArguments cmd) { var updater = new ApplicationUpdater("https://api.github.com/repos/DavidMoore/ElvUI.Updater/releases"); switch (cmd.Command) { case Command.None: break; case Command.Cleanup: var cleanupArgs = new CleanupArgs(); cleanupArgs.Target = cmd.Target; await updater.CleanupAsync(cleanupArgs); break; case Command.Install: await updater.InstallAsync(); break; case Command.Update: // Check, download and launch an update, then return immediately so the update can run. var updateArgs = new UpdateCheckArgs(); updateArgs.AllowPreRelease = true; await updater.UpdateAsync(updateArgs); return(0); case Command.ApplyUpdate: // We enter here when a downloaded update is running so it can overwrite the old exe var applyUpdateArgs = new ApplyUpdateArgs(); applyUpdateArgs.Launch = cmd.Launch; await updater.ApplyUpdateAsync(applyUpdateArgs); break; case Command.Uninstall: var uninstallArgs = new UninstallArgs(); uninstallArgs.Silent = cmd.Silent; await updater.UninstallAsync(uninstallArgs); return(0); case Command.Service: break; default: throw new ArgumentOutOfRangeException(); } return(1); }
/// <summary> /// Checks for updates. /// </summary> /// <param name="owner">The owner.</param> public void Check(IWin32Window owner) { try { _owner = owner; ApplicationUpdater applicationUpdater = new ApplicationUpdater(); applicationUpdater.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (applicationUpdater_UpdateAvailable); applicationUpdater.Version = new Version(Application.ProductVersion); applicationUpdater.CheckForUpdate(CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType); } catch { } }
public void Check(IWin32Window owner, Uri url) { try { _owner = owner; ApplicationUpdater applicationUpdater = new ApplicationUpdater(); applicationUpdater.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (applicationUpdater_UpdateAvailable); applicationUpdater.Version = new Version(Application.ProductVersion); applicationUpdater.CheckForUpdatesByUrl(url); } catch { } }
public void DownloadInstallerTest() { var updater = new ApplicationUpdater("0.11"); Console.WriteLine(updater.DownloadStoragePath); if (File.Exists(updater.DownloadStoragePath)) { File.Delete(updater.DownloadStoragePath); } updater.Download(); Assert.IsTrue(File.Exists(updater.DownloadStoragePath), "File should have been downloaded to download path"); }
public void DetectExeUpdate() { var config = new ApplicationUpdaterConfig { FullFileName = @"D:\Apps\MyApp\MyApp.update.exe", }; var updater = new ApplicationUpdater(config); var context = updater.GetUpdateContext(); Assert.True(context.IsUpdate); Assert.Equal(PackageType.Executable, context.PackageType); Assert.Equal(@"D:\Apps\MyApp\MyApp.exe", context.UpdateDestination.FullName); Assert.Equal(@"D:\Apps\MyApp\MyApp.update.exe", context.UpdateSource.FullName); }
public void CheckForNewVersion() { var updater = new ApplicationUpdater("0.01"); Assert.IsTrue(updater.NewVersionAvailable()); updater = new ApplicationUpdater("1.0"); updater.CurrentVersion = "9999.00"; Assert.IsFalse(updater.NewVersionAvailable()); updater = new ApplicationUpdater("0.78"); Console.WriteLine(updater.NewVersionAvailable()); updater = new ApplicationUpdater(typeof(Program)); Console.WriteLine(updater.NewVersionAvailable()); }
private void HandlePendingUpdate() { if (!ApplicationUpdater.UpdateFileExists) { return; } try { ApplicationUpdater.ProcessUpdateFile(); } catch (Exception ex) { Log.Error(ex, "Failed to process update file."); } }
public void CheckAndDownloadInstallerTest() { mmApp.Configuration.ApplicationUpdates.LastUpdateCheck = DateTime.Now.AddDays(-8); mmApp.Configuration.ApplicationUpdates.UpdateFrequency = 3; var updater = new ApplicationUpdater("0.11"); if (File.Exists(updater.DownloadStoragePath)) { File.Delete(updater.DownloadStoragePath); } updater.CheckDownloadExecute(true); Assert.IsTrue(File.Exists(updater.DownloadStoragePath), "File should have been downloaded to download path"); }
public void DetectDownloadsFolder() { var config = new ApplicationUpdaterConfig { FullFileName = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Downloads\MyApp.exe") }; var updater = new ApplicationUpdater(config); var context = updater.GetUpdateContext(); Assert.False(context.IsUpdate); Assert.False(context.IsDeployed); Assert.Equal(PackageType.Executable, context.PackageType); Assert.Equal(Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Programs\MyApp"), context.UpdateDestination.FullName); Assert.Equal(Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Downloads\MyApp.exe"), context.UpdateSource.FullName); }
public void DetectArchiveTemp() { var config = new ApplicationUpdaterConfig { FullFileName = Environment.ExpandEnvironmentVariables(@"%TEMP%\TempZip\MyApp.exe") }; var updater = new ApplicationUpdater(config); var context = updater.GetUpdateContext(); Assert.False(context.IsUpdate); Assert.False(context.IsDeployed); Assert.Equal(PackageType.Archive, context.PackageType); Assert.Equal(Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Programs\MyApp"), context.UpdateDestination.FullName); Assert.Equal(Environment.ExpandEnvironmentVariables(@"%TEMP%\TempZip"), context.UpdateSource.FullName); }
public void DetectArchiveUpdateWithCustomSuffix() { var config = new ApplicationUpdaterConfig { FullFileName = @"D:\Apps\MyApp\.tmp\MyApp.exe", UpdateSuffix = ".tmp" }; var updater = new ApplicationUpdater(config); var context = updater.GetUpdateContext(); Assert.True(context.IsUpdate); Assert.Equal(PackageType.Archive, context.PackageType); Assert.Equal(@"D:\Apps\MyApp", context.UpdateDestination.FullName); Assert.Equal(@"D:\Apps\MyApp\.tmp", context.UpdateSource.FullName); }
/// <summary> /// Prevents a default instance of the <see cref="MainViewModel" /> class from being created. /// </summary> private MainViewModel() : base() { // Attach the logger view model to the engine's output Logger.Subscribe(OutputViewModel.GetInstance()); ApplicationUpdater.UpdateApp(); Squalr.Engine.Projects.Compiler.Compile(true); if (Vectors.HasVectorSupport) { Logger.Log(LogLevel.Info, "Hardware acceleration enabled (vector size: " + Vector <Byte> .Count + ")"); } Logger.Log(LogLevel.Info, "Squalr started"); // this.DisplayChangeLogCommand = new RelayCommand(() => ChangeLogViewModel.GetInstance().DisplayChangeLog(new Content.ChangeLog().TransformText()), () => true); }
/// <summary> /// Handles the UpdateAvailable event of the applicationUpdater control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="UpdatesAvailableEventArgs"/> instance containing the event data.</param> void applicationUpdater_UpdateAvailable(object sender, UpdatesAvailableEventArgs e) { ApplicationUpdater ai = (ApplicationUpdater)sender; if (ai.UpdatesAvailable) { // hide the splash if its visible Util.HideSplashScreen( ); UpdateInformationForm uif = new UpdateInformationForm(ai); if (uif.ShowDialog(_owner) == DialogResult.OK) { string thisPath = this.GetType( ).Assembly.Location; string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath, ai.UpdateInfoList.GetLatestVersion( ), string.Empty); Console.WriteLine(attrString); Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString); Application.Exit( ); } } }
public void CheckVersionFrequencyTest() { var updates = new ApplicationUpdates(); updates.LastUpdateCheck = mmApp.Configuration.ApplicationUpdates.LastUpdateCheck = DateTime.Now.AddDays(-8); mmApp.Configuration.ApplicationUpdates.UpdateFrequency = 3; var updater = new ApplicationUpdater("0.11"); Assert.IsTrue(updater.IsNewVersionAvailable(true), "Should show a new version"); mmApp.Configuration.ApplicationUpdates.LastUpdateCheck = DateTime.Now.AddDays(-2); mmApp.Configuration.ApplicationUpdates.UpdateFrequency = 8; updater = new ApplicationUpdater("0.11"); Assert.IsFalse(updater.IsNewVersionAvailable(true), "Should not show a new version because not time to check yet"); }
/// <summary> /// Initializes a new instance of the <see cref="MainForm"/> class. /// </summary> public MainForm( ) { InitializeComponent( ); this.progressBar1.Maximum = 100; this.progressBar1.Minimum = 0; this.progressBar1.Value = 0; au = new ApplicationUpdater( ); au.Version = Program.ProductVersion; if (!string.IsNullOrEmpty(Program.CallingApplication)) { au.OwnerApplication = new FileInfo(Program.CallingApplication); } au.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (au_UpdateAvailable); au.UpdateException += new EventHandler <ExceptionEventArgs> (au_UpdateException); au.DownloadProgressChanged += new EventHandler <DownloadProgressEventArgs> (au_DownloadProgressChanged); au.UpdateScriptCreated += new EventHandler(au_UpdateScriptCreated); au.UpdateException += new EventHandler <ExceptionEventArgs> (au_UpdateException); }
private void updatePlugin_Click(object sender, EventArgs e) { if (this.pluginsList.SelectedItems.Count > 0) { AssemblyListViewItem alvi = this.pluginsList.SelectedItems[0] as AssemblyListViewItem; ApplicationUpdater au = new ApplicationUpdater(); au.Version = alvi.Version; this.pluginUpdateStatus.Text = "Checking updates for " + alvi.Text; au.UpdateAvailable += new EventHandler <UpdatesAvailableEventArgs> (delegate(object s, UpdatesAvailableEventArgs uae) { ApplicationUpdater ai = (ApplicationUpdater)s; ai.UpdateName = alvi.Text; this.pluginUpdateStatus.Text = "Updates available..."; if (ai.UpdatesAvailable) { UpdateInformationForm uif = new UpdateInformationForm(ai); if (uif.ShowDialog(null) == DialogResult.OK) { string thisPath = this.GetType().Assembly.Location; string attrString = string.Format(CCNetConfig.Core.Util.UserSettings.UpdateSettings.LaunchArgumentsFormat, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdateCheckType, thisPath, ai.UpdateInfoList.GetLatestVersion()); Process.Start(Path.Combine(Application.StartupPath, CCNetConfig.Core.Util.UserSettings.UpdateSettings.UpdaterApplication), attrString); Application.Exit(); } } }); au.UpdateException += new EventHandler <ExceptionEventArgs> (delegate(object s, ExceptionEventArgs ex) { MessageBox.Show(ex.Exception.Message, "Update of plugin error"); }); au.CheckForUpdatesByUrl(alvi.UpdateUrl); this.pluginUpdateStatus.Text = string.Empty; } }
private async void InitializeApplication() { try { if (IsAdministrator()) { ProgressText = LocalizationEx.GetUiString("loader_administrative_rights_available", Thread.CurrentThread.CurrentCulture); } else { ProgressText = LocalizationEx.GetUiString("loader_administrative_rights_missing", Thread.CurrentThread.CurrentCulture); await Task.Delay(3000).ConfigureAwait(false); Process.GetCurrentProcess().Kill(); } ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_check", Thread.CurrentThread.CurrentCulture); if (PrerequisiteHelper.IsRedistributablePackageInstalled()) { ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_already_installed", Thread.CurrentThread.CurrentCulture); } else { ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_installing", Thread.CurrentThread.CurrentCulture); //minisign needs this (to verify the installer with libsodium) await PrerequisiteHelper.DownloadAndInstallRedistributablePackage(); if (PrerequisiteHelper.IsRedistributablePackageInstalled()) { ProgressText = LocalizationEx.GetUiString("loader_redistributable_package_ready", Thread.CurrentThread.CurrentCulture); await Task.Delay(1000).ConfigureAwait(false); } } if (Properties.Settings.Default.AutoUpdate) { ProgressText = LocalizationEx.GetUiString("loader_checking_version", Thread.CurrentThread.CurrentCulture); //TODO: remove in future version (for now we only have one channel) Properties.Settings.Default.MinUpdateType = 2; Properties.Settings.Default.Save(); var minUpdateType = (UpdateType)Properties.Settings.Default.MinUpdateType; var update = await ApplicationUpdater.CheckForRemoteUpdateAsync(minUpdateType).ConfigureAwait(false); if (update.CanUpdate) { ProgressText = string.Format(LocalizationEx.GetUiString("loader_new_version_found", Thread.CurrentThread.CurrentCulture), update.Update.Version); await Task.Delay(200).ConfigureAwait(false); var installer = await StartRemoteUpdateDownload(update).ConfigureAwait(false); if (!string.IsNullOrEmpty(installer) && File.Exists(installer)) { ProgressText = LocalizationEx.GetUiString("loader_starting_update", Thread.CurrentThread.CurrentCulture); await Task.Delay(200).ConfigureAwait(false); Process.Start(installer); Process.GetCurrentProcess().Kill(); } else { await Task.Delay(500).ConfigureAwait(false); ProgressText = LocalizationEx.GetUiString("loader_update_failed", Thread.CurrentThread.CurrentCulture); } } else { ProgressText = LocalizationEx.GetUiString("loader_latest_version", Thread.CurrentThread.CurrentCulture); } } else { await Task.Delay(500).ConfigureAwait(false); } ProgressText = string.Format(LocalizationEx.GetUiString("loader_validate_folder", Thread.CurrentThread.CurrentCulture), Global.DnsCryptProxyFolder); var validatedFolder = ValidateDnsCryptProxyFolder(); if (validatedFolder.Count == 0) { ProgressText = LocalizationEx.GetUiString("loader_all_files_available", Thread.CurrentThread.CurrentCulture); } else { var fileErrors = ""; foreach (var pair in validatedFolder) { fileErrors += $"{pair.Key}: {pair.Value}\n"; } ProgressText = string.Format( LocalizationEx.GetUiString("loader_missing_files", Thread.CurrentThread.CurrentCulture).Replace("\\n", "\n"), Global.DnsCryptProxyFolder, fileErrors, Global.ApplicationName); await Task.Delay(5000).ConfigureAwait(false); Process.GetCurrentProcess().Kill(); } ProgressText = string.Format(LocalizationEx.GetUiString("loader_loading", Thread.CurrentThread.CurrentCulture), Global.DnsCryptConfigurationFile); if (DnscryptProxyConfigurationManager.LoadConfiguration()) { ProgressText = string.Format(LocalizationEx.GetUiString("loader_successfully_loaded", Thread.CurrentThread.CurrentCulture), Global.DnsCryptConfigurationFile); _mainViewModel.DnscryptProxyConfiguration = DnscryptProxyConfigurationManager.DnscryptProxyConfiguration; } else { ProgressText = string.Format(LocalizationEx.GetUiString("loader_failed_loading", Thread.CurrentThread.CurrentCulture), Global.DnsCryptConfigurationFile); await Task.Delay(5000).ConfigureAwait(false); Process.GetCurrentProcess().Kill(); } ProgressText = LocalizationEx.GetUiString("loader_loading_network_cards", Thread.CurrentThread.CurrentCulture); List <LocalNetworkInterface> localNetworkInterfaces; if (DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.listen_addresses.Contains(Global.GlobalResolver)) { var dnsServer = new List <string> { Global.DefaultResolverIpv4, Global.DefaultResolverIpv6 }; localNetworkInterfaces = LocalNetworkInterfaceManager.GetLocalNetworkInterfaces(dnsServer); } else { localNetworkInterfaces = LocalNetworkInterfaceManager.GetLocalNetworkInterfaces( DnscryptProxyConfigurationManager.DnscryptProxyConfiguration.listen_addresses.ToList()); } _mainViewModel.LocalNetworkInterfaces = new BindableCollection <LocalNetworkInterface>(); _mainViewModel.LocalNetworkInterfaces.AddRange(localNetworkInterfaces); _mainViewModel.Initialize(); ProgressText = LocalizationEx.GetUiString("loader_starting", Thread.CurrentThread.CurrentCulture); if (Properties.Settings.Default.TrayMode) { Execute.OnUIThread(() => _windowManager.ShowWindow(_systemTrayViewModel)); Execute.OnUIThread(() => _systemTrayViewModel.ShowWindow()); } else { Execute.OnUIThread(() => _windowManager.ShowWindow(_mainViewModel)); } TryClose(true); } catch (Exception exception) { Log.Error(exception); } }
public void CheckForNewVersion(bool force = false) { var updater = new ApplicationUpdater(typeof(Program)); //updater.LastCheck = DateTime.UtcNow.AddDays(-50); if (updater.NewVersionAvailable(!force)) { if (MessageBox.Show(updater.VersionInfo.Detail + "\r\n" + "Do you want to download and install this version?", updater.VersionInfo.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { updater.DownloadProgressChanged += updater_DownloadProgressChanged; ShowStatus("Downloading Update - Version " + updater.VersionInfo.Version); updater.Download(); updater.ExecuteDownloadedFile(); ShowStatus("Download completed."); Application.Exit(); } } App.Configuration.CheckForUpdates.LastUpdateCheck = DateTime.UtcNow.Date; }
private async void CheckForApplicationUpdate() { var updater = new ApplicationUpdater("VisualJsonEditor.msi", GetType().Assembly, "http://rsuter.com/Projects/VisualJsonEditor/updates.php"); await updater.CheckForUpdate(this); }