private async Task UpdateAsync()
        {
            var manager = new UpdateManager(
                AssemblyMetadata.FromAssembly(
                    Assembly.GetEntryAssembly(),
                    System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName),
                new GithubPackageResolver("markuskonojacki", "PhexensWuerfelraum", "PhexensWuerfelraum-*.zip"),
                new ZipPackageExtractor());
            {
                var resultCheckForUpdatesAsync = await manager.CheckForUpdatesAsync();

                if (resultCheckForUpdatesAsync.CanUpdate)
                {
                    ChatnRollViewModel.OpenUpdateInfoCommand.Execute(null);

                    // Prepare an update by downloading and extracting the package
                    // (supports progress reporting and cancellation)
                    await manager.PrepareUpdateAsync(resultCheckForUpdatesAsync.LastVersion);

                    if (manager.IsUpdatePrepared(resultCheckForUpdatesAsync.LastVersion))
                    {
                        // Launch an executable that will apply the update
                        manager.LaunchUpdater(resultCheckForUpdatesAsync.LastVersion, true);

                        // Terminate the running application so that the updater can overwrite files
                        Environment.Exit(0);
                    }
                }
            }
        }
 static void CheckForUpdates()
 {
     // Configure to look for packages in specified directory and treat them as zips
     using (var manager = new UpdateManager(
                AssemblyMetadata.FromAssembly(
                    Assembly.GetEntryAssembly(),
                    Process.GetCurrentProcess().MainModule.FileName),
                new LocalPackageResolver("C:\\UpdateTest\\Packages", "*.zip"),
                new ZipPackageExtractor()))
     {
         // Check for updates
         var result = manager.CheckForUpdatesAsync().Result;
         if (result.CanUpdate)
         {
             string            message = $"v{result.LastVersion} is available. Would you like to update now?";
             string            caption = "Update Available";
             MessageBoxButtons buttons = MessageBoxButtons.YesNo;
             DialogResult      dialogResult;
             dialogResult = MessageBox.Show(message, caption, buttons);
             if (dialogResult == DialogResult.Yes)
             {
                 var form = new UpdateForm(manager, result);
                 Application.Run(form);
                 form.StartUpdate();
             }
         }
     }
 }
示例#3
0
        private static UpdateManager CreateUpdateManager()
        {
            var entryAssembly    = Assembly.GetEntryAssembly();
            var executablePath   = Process.GetCurrentProcess().MainModule.FileName;
            var assemblyMetaData = AssemblyMetadata.FromAssembly(entryAssembly, executablePath);

            return(new UpdateManager(
                       assemblyMetaData,
                       new GithubPackageResolver("rik-smeets", "Harmonia", "*.zip"),
                       new ZipPackageExtractor()));
        }
示例#4
0
        public UpdateService(bool isUpdateCheckDisabled, string updatesPath)
        {
            IsUpdateCheckEnabled = !isUpdateCheckDisabled;
            _updateManager       = new UpdateManager(
                AssemblyMetadata.FromAssembly(Assembly.GetEntryAssembly() ?? Assembly.GetAssembly(typeof(UpdateService))),
                new LocalPackageResolver(updatesPath, "TogglDesktopInstaller*.exe"),
                new NsisPackageExtractor());

            Toggl.OnUpdateDownloadStatus
            .Where(x => x.DownloadStatus != Toggl.DownloadStatus.Done)
            .Subscribe(_updateStatusSubject);
            Toggl.OnUpdateDownloadStatus
            .Where(x => x.DownloadStatus == Toggl.DownloadStatus.Done)
            .Subscribe(PrepareUpdate);
            UpdateStatus  = _updateStatusSubject.AsObservable();
            UpdateChannel = new BehaviorSubject <string>("stable");
            UpdateChannel.DistinctUntilChanged().Skip(1).Subscribe(channel => Toggl.SetUpdateChannel(channel));
        }
示例#5
0
        public Updater(UpdateMode updateMode = UpdateMode.Always, bool byPassUpdateLoopProtection = false)
        {
            UpdateMode = updateMode;
            ByPassUpdateLoopProtection = byPassUpdateLoopProtection;

            var os   = "win";
            var arch = Environment.Is64BitOperatingSystem ? "64" : "86";

            var assemblyMetadata =
                AssemblyMetadata.FromAssembly(
                    Assembly.GetEntryAssembly(),
                    System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);

            CurrentVersion = assemblyMetadata.Version;

            UpdateManager =
                new UpdateManager(
                    assemblyMetadata,
                    new GithubPackageResolver("litetex", "SWAPS", $"SWAPS-{os}-x{arch}*"),
                    new ZipPackageExtractor()
                    );
        }
        private void CheckForUpdates()
        {
            Task.Run(async() =>
            {
                while (true)
                {
                    _manager = new UpdateManager(
                        AssemblyMetadata.FromAssembly(
                            Assembly.GetEntryAssembly(),
                            System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName),
                        new GithubPackageResolver("kevinlay7", "RocketLeagueTracker", "*.zip"), new ZipPackageExtractor());
                    var check = await _manager.CheckForUpdatesAsync();

                    if (!check.CanUpdate)
                    {
                        await Task.Delay(60000);
                        continue;
                    }

                    UpdateButton.Dispatcher.Invoke(() => UpdateButton.Visibility = Visibility.Visible);
                    break;
                }
            });
        }
示例#7
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                desktop.MainWindow = new MainWindow
                {
                    DataContext = new MainWindowViewModel(),
                };

#if !DEBUG
                var os = string.Empty;
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    os = "win";
                }
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    os = "linux";
                }
                os += "-" + RuntimeInformation.OSArchitecture.ToString().ToLower();

                // Configure to look for packages in specified directory and treat them as zips
                manager = new UpdateManager(
                    AssemblyMetadata.FromAssembly(
                        Assembly.GetEntryAssembly(),
                        System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName),
                    new GithubPackageResolver("ipocsmr", "ipocs.dpt", "*" + os + "*"),
                    new ZipPackageExtractor());
                // Check for new version and, if available, perform full update and restart
                // Check for updates
                _ = manager.CheckForUpdatesAsync().ContinueWith(resultTask =>
                {
                    var result = resultTask.Result;
                    if (result.CanUpdate)
                    {
                        Dispatcher.UIThread.InvokeAsync(() =>
                        {
                            MessageBox.Show(desktop.MainWindow, "There's a new version available. Do you want to download and install?", "New version", MessageBox.MessageBoxButtons.YesNo).ContinueWith((boxResult) =>
                            {
                                if (boxResult.Result != MessageBox.MessageBoxResult.Yes)
                                {
                                    return;
                                }
                                // Prepare an update by downloading and extracting the package
                                // (supports progress reporting and cancellation)
                                _ = manager.PrepareUpdateAsync(result.LastVersion).ContinueWith((prepareTask) =>
                                {
                                    // Launch an executable that will apply the update
                                    // (can be instructed to restart the application afterwards)
                                    manager.LaunchUpdater(result.LastVersion);

                                    // Terminate the running application so that the updater can overwrite files
                                    System.Environment.Exit(0);
                                });
                            });
                        });
                    }
                    else
                    {
                        manager = null;
                    }
                });
#endif
            }

            base.OnFrameworkInitializationCompleted();
        }