Browse Source

Basic WPF Sparkle setup (note JsonConfiguration is not yet active, issue opened)

pull/2998/head
Christoph Wille 2 years ago
parent
commit
22147ce6bc
  1. 1
      ILSpy/ILSpy.csproj
  2. 41
      ILSpy/MainWindow.xaml.cs

1
ILSpy/ILSpy.csproj

@ -45,6 +45,7 @@
<PackageReference Include="Microsoft.VisualStudio.Composition" Version="17.4.16" /> <PackageReference Include="Microsoft.VisualStudio.Composition" Version="17.4.16" />
<PackageReference Include="DataGridExtensions" Version="2.5.14" /> <PackageReference Include="DataGridExtensions" Version="2.5.14" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="NetSparkleUpdater.UI.WPF" Version="2.2.2" />
<PackageReference Include="TomsToolbox.Wpf.Styles" Version="$(WpfStylesToolboxVersion)" /> <PackageReference Include="TomsToolbox.Wpf.Styles" Version="$(WpfStylesToolboxVersion)" />
</ItemGroup> </ItemGroup>

41
ILSpy/MainWindow.xaml.cs

@ -57,6 +57,11 @@ using ICSharpCode.TreeView;
using Microsoft.Win32; using Microsoft.Win32;
using NetSparkleUpdater.Enums;
using NetSparkleUpdater.SignatureVerifiers;
using NetSparkleUpdater;
using System.Runtime.InteropServices;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
/// <summary> /// <summary>
@ -72,6 +77,8 @@ namespace ICSharpCode.ILSpy
AssemblyList assemblyList; AssemblyList assemblyList;
AssemblyListTreeNode assemblyListTreeNode; AssemblyListTreeNode assemblyListTreeNode;
SparkleUpdater _sparkle;
static MainWindow instance; static MainWindow instance;
public static MainWindow Instance { public static MainWindow Instance {
@ -895,6 +902,37 @@ namespace ICSharpCode.ILSpy
} }
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => OpenAssemblies(spySettings))); 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) void OpenAssemblies(ILSpySettings spySettings)
@ -951,6 +989,9 @@ namespace ICSharpCode.ILSpy
public async Task ShowMessageIfUpdatesAvailableAsync(ILSpySettings spySettings, bool forceCheck = false) 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; string downloadUrl;
if (forceCheck) if (forceCheck)
{ {

Loading…
Cancel
Save