From 22147ce6bc3cc45ef3871f6b4c7fdef13303160f Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Sun, 4 Jun 2023 13:47:14 +0200 Subject: [PATCH] Basic WPF Sparkle setup (note JsonConfiguration is not yet active, issue opened) --- ILSpy/ILSpy.csproj | 1 + ILSpy/MainWindow.xaml.cs | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index d33163bad..95a2d755e 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -45,6 +45,7 @@ + diff --git a/ILSpy/MainWindow.xaml.cs b/ILSpy/MainWindow.xaml.cs index eaa65475b..f474d4093 100644 --- a/ILSpy/MainWindow.xaml.cs +++ b/ILSpy/MainWindow.xaml.cs @@ -57,6 +57,11 @@ using ICSharpCode.TreeView; using Microsoft.Win32; +using NetSparkleUpdater.Enums; +using NetSparkleUpdater.SignatureVerifiers; +using NetSparkleUpdater; +using System.Runtime.InteropServices; + namespace ICSharpCode.ILSpy { /// @@ -72,6 +77,8 @@ namespace ICSharpCode.ILSpy AssemblyList assemblyList; AssemblyListTreeNode assemblyListTreeNode; + SparkleUpdater _sparkle; + static MainWindow instance; public static MainWindow Instance { @@ -895,6 +902,37 @@ namespace ICSharpCode.ILSpy } Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => OpenAssemblies(spySettings))); + + + var s = new UpdateSettings(spySettings); + bool automaticCheckingEnabled = s.AutomaticUpdateCheckEnabled; +#if DEBUG + // automaticCheckingEnabled = false; +#endif + + if (automaticCheckingEnabled) + EnableSparkleUpdateChecking(); + } + + void EnableSparkleUpdateChecking() + { + // We'd need two appcast.xml's, one for x64 and one for arm64 + if (RuntimeInformation.ProcessArchitecture != Architecture.X64) + return; + + // https://github.com/NetSparkleUpdater/NetSparkle/blob/develop/src/NetSparkle.Samples.NetCore.WPF/MainWindow.xaml.cs + string sparkleSettingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode\\ILSpy-sparkle.json"); + + _sparkle = new SparkleUpdater( + "https://ilspy.net/appcast.xml", + new Ed25519Checker(SecurityMode.Strict, "s2P6MPexSRSjod77aWUjgVKj/gKYYAeqgHY/0Gf8b78=") + ) { + UIFactory = new NetSparkleUpdater.UI.WPF.UIFactory(null), + RelaunchAfterUpdate = false, + CustomInstallerArguments = "", + // Configuration = new JSONConfiguration(null, sparkleSettingsPath) + }; + _sparkle.StartLoop(true); } void OpenAssemblies(ILSpySettings spySettings) @@ -951,6 +989,9 @@ namespace ICSharpCode.ILSpy public async Task ShowMessageIfUpdatesAvailableAsync(ILSpySettings spySettings, bool forceCheck = false) { + // TODO: Properly replace old code-paths, this is for UI testing of Netsparkle only + var info = await _sparkle.CheckForUpdatesAtUserRequest(); + string downloadUrl; if (forceCheck) {