Unify upgrade process and add update progress bar
This commit is contained in:
parent
ded58f687d
commit
d787843fd2
@ -21,13 +21,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@ -16,13 +16,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<!--Avalonia doesen't support TrimMode=link currently,but we are working on that https://github.com/AvaloniaUI/Avalonia/issues/6892 -->
|
||||
<TrimMode>copyused</TrimMode>
|
||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||
<ApplicationIcon>libation.ico</ApplicationIcon>
|
||||
<AssemblyName>Libation</AssemblyName>
|
||||
@ -17,13 +15,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -109,6 +101,7 @@
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview4 " />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview4" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview4" />
|
||||
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -25,6 +25,9 @@ namespace LibationAvalonia.ViewModels
|
||||
public ProcessQueueViewModel ProcessQueue { get; } = new ProcessQueueViewModel();
|
||||
public ProductsDisplayViewModel ProductsDisplay { get; } = new ProductsDisplayViewModel();
|
||||
|
||||
private double? _downloadProgress = null;
|
||||
public double? DownloadProgress { get => _downloadProgress; set => this.RaiseAndSetIfChanged(ref _downloadProgress, value); }
|
||||
|
||||
|
||||
/// <summary> Library filterting query </summary>
|
||||
public string FilterString { get => _filterString; set => this.RaiseAndSetIfChanged(ref _filterString, value); }
|
||||
|
||||
@ -1,87 +0,0 @@
|
||||
using AppScaffolding;
|
||||
using LibationAvalonia.Dialogs;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationAvalonia.Views
|
||||
{
|
||||
public partial class MainWindow
|
||||
{
|
||||
private void Configure_Update()
|
||||
{
|
||||
Opened += async (_, _) => await checkForUpdates();
|
||||
}
|
||||
|
||||
private async Task checkForUpdates()
|
||||
{
|
||||
async Task<string> downloadUpdate(UpgradeProperties upgradeProperties)
|
||||
{
|
||||
if (upgradeProperties.ZipUrl is null)
|
||||
{
|
||||
Serilog.Log.Logger.Warning("Download link for new version not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Silently download the update in the background, save it to a temp file.
|
||||
|
||||
var zipFile = Path.Combine(Path.GetTempPath(), Path.GetFileName(upgradeProperties.ZipUrl));
|
||||
|
||||
Serilog.Log.Logger.Information($"Downloading {zipFile}");
|
||||
|
||||
try
|
||||
{
|
||||
System.Net.Http.HttpClient cli = new();
|
||||
using var fs = File.OpenWrite(zipFile);
|
||||
using var dlStream = await cli.GetStreamAsync(new Uri(upgradeProperties.ZipUrl));
|
||||
await dlStream.CopyToAsync(fs);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Failed to download the update: {pdate}", upgradeProperties.ZipUrl);
|
||||
return null;
|
||||
}
|
||||
return zipFile;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var upgradeProperties = await Task.Run(LibationScaffolding.GetLatestRelease);
|
||||
if (upgradeProperties is null) return;
|
||||
|
||||
const string ignoreUpdate = "IgnoreUpdate";
|
||||
var config = Configuration.Instance;
|
||||
|
||||
if (config.GetString(propertyName: ignoreUpdate) == upgradeProperties.LatestRelease.ToString())
|
||||
return;
|
||||
|
||||
var interop = InteropFactory.Create();
|
||||
|
||||
if (!interop.CanUpdate)
|
||||
Serilog.Log.Logger.Information("Can't perform update automatically");
|
||||
|
||||
var notificationResult = await new UpgradeNotificationDialog(upgradeProperties, interop.CanUpdate).ShowDialog<DialogResult>(this);
|
||||
|
||||
if (notificationResult == DialogResult.Ignore)
|
||||
config.SetString(upgradeProperties.LatestRelease.ToString(), ignoreUpdate);
|
||||
|
||||
if (notificationResult != DialogResult.OK) return;
|
||||
|
||||
//Download the update file in the background,
|
||||
string updateBundle = await downloadUpdate(upgradeProperties);
|
||||
|
||||
if (string.IsNullOrEmpty(updateBundle) || !File.Exists(updateBundle)) return;
|
||||
|
||||
//Install the update
|
||||
Serilog.Log.Logger.Information($"Begin running auto-updater");
|
||||
interop.InstallUpdate(updateBundle);
|
||||
Serilog.Log.Logger.Information($"Completed running auto-updater");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "An error occured while checking for app updates.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Source/LibationAvalonia/Views/MainWindow.Upgrade.cs
Normal file
33
Source/LibationAvalonia/Views/MainWindow.Upgrade.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using Avalonia.Threading;
|
||||
using LibationAvalonia.Dialogs;
|
||||
using LibationUiBase;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationAvalonia.Views
|
||||
{
|
||||
public partial class MainWindow
|
||||
{
|
||||
private void Configure_Update()
|
||||
{
|
||||
setProgressVisible(false);
|
||||
#if !DEBUG
|
||||
var upgrader = new Upgrader();
|
||||
upgrader.DownloadProgress += async (_, e) => await Dispatcher.UIThread.InvokeAsync(() => _viewModel.DownloadProgress = e.ProgressPercentage);
|
||||
upgrader.DownloadBegin += async (_, _) => await Dispatcher.UIThread.InvokeAsync(() => setProgressVisible(false));
|
||||
upgrader.DownloadCompleted += async (_, _) => await Dispatcher.UIThread.InvokeAsync(() => setProgressVisible(true));
|
||||
|
||||
Opened += async (_, _) => await upgrader.CheForUpgradeAsync(UpgradeAvailable);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void setProgressVisible(bool visible) => _viewModel.DownloadProgress = visible ? 0 : null;
|
||||
|
||||
private async Task UpgradeAvailable(UpgradeEventArgs e)
|
||||
{
|
||||
var notificationResult = await new UpgradeNotificationDialog(e.UpgradeProperties, e.CapUpgrade).ShowDialog<DialogResult>(this);
|
||||
|
||||
e.Ignore = notificationResult == DialogResult.Ignore;
|
||||
e.InstallUpdate = notificationResult == DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,9 +194,16 @@
|
||||
</Border>
|
||||
|
||||
<!-- Bottom Status Strip -->
|
||||
<Grid Grid.Row="3" Margin="0,10,0,0" VerticalAlignment="Bottom" ColumnDefinitions="*,Auto">
|
||||
<TextBlock FontSize="14" Grid.Column="0" Text="{Binding VisibleCountText}" VerticalAlignment="Center" />
|
||||
<TextBlock FontSize="14" Grid.Column="1" Text="{Binding StatusCountText}" VerticalAlignment="Center" HorizontalAlignment="Right" />
|
||||
<Grid Grid.Row="3" Margin="0,10,0,0" VerticalAlignment="Bottom" ColumnDefinitions="Auto,Auto,*,Auto">
|
||||
<Grid.Styles>
|
||||
<Style Selector="ProgressBar:horizontal">
|
||||
<Setter Property="MinWidth" Value="100" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<TextBlock FontSize="14" Grid.Column="0" Text="Upgrading:" VerticalAlignment="Center" IsVisible="{Binding DownloadProgress, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<ProgressBar Grid.Column="1" Margin="5,0,10,0" VerticalAlignment="Stretch" Width="100" Value="{Binding DownloadProgress}" IsVisible="{Binding DownloadProgress, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
||||
<TextBlock FontSize="14" Grid.Column="2" Text="{Binding VisibleCountText}" VerticalAlignment="Center" />
|
||||
<TextBlock FontSize="14" Grid.Column="3" Text="{Binding StatusCountText}" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@ -40,9 +40,7 @@ namespace LibationAvalonia.Views
|
||||
Configure_Export();
|
||||
Configure_Settings();
|
||||
Configure_ProcessQueue();
|
||||
#if !DEBUG
|
||||
Configure_Update();
|
||||
#endif
|
||||
Configure_Filter();
|
||||
// misc which belongs in winforms app but doesn't have a UI element
|
||||
Configure_NonUI();
|
||||
|
||||
@ -11,13 +11,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
|
||||
148
Source/LibationUiBase/Upgrader.cs
Normal file
148
Source/LibationUiBase/Upgrader.cs
Normal file
@ -0,0 +1,148 @@
|
||||
using AppScaffolding;
|
||||
using Dinah.Core.Net.Http;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationUiBase
|
||||
{
|
||||
public class UpgradeEventArgs
|
||||
{
|
||||
public UpgradeProperties UpgradeProperties { get; internal init; }
|
||||
public bool CapUpgrade { get; internal init; }
|
||||
private bool _ignore = false;
|
||||
private bool _installUpdate = true;
|
||||
public bool Ignore
|
||||
{
|
||||
get => _ignore;
|
||||
set
|
||||
{
|
||||
_ignore = value;
|
||||
_installUpdate &= !Ignore;
|
||||
}
|
||||
}
|
||||
public bool InstallUpdate
|
||||
{
|
||||
get => _installUpdate;
|
||||
set
|
||||
{
|
||||
_installUpdate = value;
|
||||
_ignore &= !InstallUpdate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Upgrader
|
||||
{
|
||||
public event EventHandler DownloadBegin;
|
||||
public event EventHandler<DownloadProgress> DownloadProgress;
|
||||
public event EventHandler<bool> DownloadCompleted;
|
||||
|
||||
public async Task CheForUpgradeAsync(Func<UpgradeEventArgs,Task> upgradeAvailableHandler)
|
||||
{
|
||||
try
|
||||
{
|
||||
var upgradeProperties = await Task.Run(LibationScaffolding.GetLatestRelease);
|
||||
if (upgradeProperties is null) return;
|
||||
|
||||
const string ignoreUpdate = "IgnoreUpdate";
|
||||
var config = Configuration.Instance;
|
||||
|
||||
if (config.GetString(propertyName: ignoreUpdate) == upgradeProperties.LatestRelease.ToString())
|
||||
return;
|
||||
|
||||
var interop = InteropFactory.Create();
|
||||
|
||||
if (!interop.CanUpdate)
|
||||
Serilog.Log.Logger.Information("Can't perform update automatically");
|
||||
|
||||
var upgradeEventArgs = new UpgradeEventArgs
|
||||
{
|
||||
UpgradeProperties = upgradeProperties,
|
||||
CapUpgrade = interop.CanUpdate
|
||||
};
|
||||
|
||||
await upgradeAvailableHandler(upgradeEventArgs);
|
||||
|
||||
if (upgradeEventArgs.Ignore)
|
||||
config.SetString(upgradeProperties.LatestRelease.ToString(), ignoreUpdate);
|
||||
|
||||
if (!upgradeEventArgs.InstallUpdate) return;
|
||||
|
||||
//Download the update file in the background,
|
||||
DownloadBegin?.Invoke(this, EventArgs.Empty);
|
||||
string updateBundle = await DownloadUpgradeAsync(upgradeProperties);
|
||||
|
||||
if (string.IsNullOrEmpty(updateBundle) || !File.Exists(updateBundle))
|
||||
{
|
||||
DownloadCompleted?.Invoke(this, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadCompleted?.Invoke(this, true);
|
||||
|
||||
//Install the update
|
||||
Serilog.Log.Logger.Information($"Begin running auto-updater");
|
||||
interop.InstallUpdate(updateBundle);
|
||||
Serilog.Log.Logger.Information($"Completed running auto-updater");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "An error occured while checking for app updates.");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> DownloadUpgradeAsync(UpgradeProperties upgradeProperties)
|
||||
{
|
||||
if (upgradeProperties.ZipUrl is null)
|
||||
{
|
||||
Serilog.Log.Logger.Warning("Download link for new version not found");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Silently download the update in the background, save it to a temp file.
|
||||
|
||||
var zipFile = Path.Combine(Path.GetTempPath(), Path.GetFileName(upgradeProperties.ZipUrl));
|
||||
|
||||
Serilog.Log.Logger.Information($"Downloading {zipFile}");
|
||||
|
||||
try
|
||||
{
|
||||
using var dlClient = new HttpClient();
|
||||
using var response = await dlClient.GetAsync(upgradeProperties.ZipUrl, HttpCompletionOption.ResponseHeadersRead);
|
||||
using var dlStream = await response.Content.ReadAsStreamAsync();
|
||||
using var tempFile = File.OpenWrite(zipFile);
|
||||
|
||||
int read;
|
||||
long totalRead = 0;
|
||||
Memory<byte> buffer = new byte[128 * 1024];
|
||||
long contentLength = response.Content.Headers.ContentLength ?? 0;
|
||||
|
||||
while ((read = await dlStream.ReadAsync(buffer)) > 0)
|
||||
{
|
||||
await tempFile.WriteAsync(buffer[..read]);
|
||||
totalRead += read;
|
||||
|
||||
DownloadProgress?.Invoke(
|
||||
this,
|
||||
new DownloadProgress
|
||||
{
|
||||
BytesReceived = totalRead,
|
||||
TotalBytesToReceive = contentLength,
|
||||
ProgressPercentage = contentLength > 0 ? 100d * totalRead / contentLength : 0
|
||||
});
|
||||
}
|
||||
|
||||
return zipFile;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Failed to download the update: {pdate}", upgradeProperties.ZipUrl);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Source/LibationWinForms/Form1.Designer.cs
generated
17
Source/LibationWinForms/Form1.Designer.cs
generated
@ -71,6 +71,8 @@
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.upgradePb = new System.Windows.Forms.ToolStripProgressBar();
|
||||
this.upgradeLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.visibleCountLbl = new LibationWinForms.FormattableToolStripStatusLabel();
|
||||
this.springLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.backupsCountsLbl = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
@ -418,6 +420,8 @@
|
||||
//
|
||||
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(40, 40);
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.upgradeLbl,
|
||||
this.upgradePb,
|
||||
this.visibleCountLbl,
|
||||
this.springLbl,
|
||||
this.backupsCountsLbl,
|
||||
@ -429,6 +433,17 @@
|
||||
this.statusStrip1.Size = new System.Drawing.Size(1025, 22);
|
||||
this.statusStrip1.TabIndex = 6;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
// upgradePb
|
||||
//
|
||||
this.upgradePb.Name = "upgradePb";
|
||||
this.upgradePb.Size = new System.Drawing.Size(100, 16);
|
||||
//
|
||||
// upgradeLbl
|
||||
//
|
||||
this.upgradeLbl.Name = "upgradeLbl";
|
||||
this.upgradeLbl.Size = new System.Drawing.Size(66, 17);
|
||||
this.upgradeLbl.Text = "Upgrading:";
|
||||
//
|
||||
// visibleCountLbl
|
||||
//
|
||||
@ -671,5 +686,7 @@
|
||||
private System.Windows.Forms.Button removeBooksBtn;
|
||||
private System.Windows.Forms.Button doneRemovingBtn;
|
||||
private System.Windows.Forms.ToolStripMenuItem setPdfDownloadedManualToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripProgressBar upgradePb;
|
||||
private System.Windows.Forms.ToolStripStatusLabel upgradeLbl;
|
||||
}
|
||||
}
|
||||
|
||||
34
Source/LibationWinForms/Form1.Upgrade.cs
Normal file
34
Source/LibationWinForms/Form1.Upgrade.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using LibationUiBase;
|
||||
using LibationWinForms.Dialogs;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
public partial class Form1
|
||||
{
|
||||
private void Configure_Update()
|
||||
{
|
||||
setProgressVisible(false);
|
||||
#if !DEBUG
|
||||
var upgrader = new Upgrader();
|
||||
upgrader.DownloadProgress += (_, e) => Invoke(() => upgradePb.Value = int.Max(0, int.Min(100, (int)(e.ProgressPercentage ?? 0))));
|
||||
upgrader.DownloadBegin += (_, _) => Invoke(() => setProgressVisible(true));
|
||||
upgrader.DownloadCompleted += (_, _) => Invoke(() => setProgressVisible(false));
|
||||
|
||||
Shown += async (_, _) => await upgrader.CheForUpgradeAsync(UpgradeAvailable);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void setProgressVisible(bool visible) => upgradeLbl.Visible = upgradePb.Visible = visible;
|
||||
|
||||
private Task UpgradeAvailable(UpgradeEventArgs e)
|
||||
{
|
||||
var notificationResult = new UpgradeNotificationDialog(e.UpgradeProperties).ShowDialog(this);
|
||||
|
||||
e.Ignore = notificationResult == System.Windows.Forms.DialogResult.Ignore;
|
||||
e.InstallUpdate = notificationResult == System.Windows.Forms.DialogResult.Yes;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -51,6 +51,7 @@ namespace LibationWinForms
|
||||
Configure_Settings();
|
||||
Configure_ProcessQueue();
|
||||
Configure_Filter();
|
||||
Configure_Update();
|
||||
// misc which belongs in winforms app but doesn't have a UI element
|
||||
Configure_NonUI();
|
||||
|
||||
|
||||
@ -13,19 +13,12 @@
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<StartupObject />
|
||||
<IsPublishable>true</IsPublishable>
|
||||
<!-- Version is now in AppScaffolding.csproj -->
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -44,7 +37,6 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.6" />
|
||||
<PackageReference Include="Dinah.Core.WindowsDesktop" Version="7.2.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -51,9 +51,6 @@ namespace LibationWinForms
|
||||
|
||||
MessageBoxLib.VerboseLoggingWarning_ShowIfTrue();
|
||||
|
||||
#if !DEBUG
|
||||
checkForUpdate();
|
||||
#endif
|
||||
// logging is init'd here
|
||||
AppScaffolding.LibationScaffolding.RunPostMigrationScaffolding(config);
|
||||
}
|
||||
@ -165,31 +162,6 @@ namespace LibationWinForms
|
||||
// - long running. won't get a chance to finish in cli. don't move to app scaffolding
|
||||
}
|
||||
|
||||
private static void checkForUpdate()
|
||||
{
|
||||
AppScaffolding.UpgradeProperties upgradeProperties;
|
||||
|
||||
try
|
||||
{
|
||||
upgradeProperties = AppScaffolding.LibationScaffolding.GetLatestRelease();
|
||||
if (upgradeProperties is null)
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBoxLib.ShowAdminAlert(null, "Error checking for update", "Error checking for update", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (upgradeProperties.ZipUrl is null)
|
||||
{
|
||||
MessageBox.Show(upgradeProperties.HtmlUrl, "New version available");
|
||||
return;
|
||||
}
|
||||
|
||||
Updater.Run(upgradeProperties);
|
||||
}
|
||||
|
||||
private static void postLoggingGlobalExceptionHandling()
|
||||
{
|
||||
// this line is all that's needed for strict handling
|
||||
|
||||
@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using AppScaffolding;
|
||||
using AutoUpdaterDotNET;
|
||||
using LibationFileManager;
|
||||
using LibationWinForms.Dialogs;
|
||||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
public static class Updater
|
||||
{
|
||||
public static void Run(UpgradeProperties upgradeProperties)
|
||||
{
|
||||
string latestVersionOnServer = upgradeProperties.LatestRelease.ToString();
|
||||
string downloadZipUrl = upgradeProperties.ZipUrl;
|
||||
AutoUpdater.ParseUpdateInfoEvent +=
|
||||
args => args.UpdateInfo = new()
|
||||
{
|
||||
CurrentVersion = latestVersionOnServer,
|
||||
DownloadURL = downloadZipUrl,
|
||||
ChangelogURL = LibationScaffolding.RepositoryLatestUrl
|
||||
};
|
||||
|
||||
void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args)
|
||||
{
|
||||
if (args is null || !args.IsUpdateAvailable)
|
||||
return;
|
||||
|
||||
const string ignoreUpdate = "IgnoreUpdate";
|
||||
var config = Configuration.Instance;
|
||||
|
||||
if (config.GetString(propertyName: ignoreUpdate) == args.CurrentVersion)
|
||||
return;
|
||||
|
||||
var notificationResult = new UpgradeNotificationDialog(upgradeProperties).ShowDialog();
|
||||
|
||||
if (notificationResult == DialogResult.Ignore)
|
||||
config.SetString(upgradeProperties.LatestRelease.ToString(), ignoreUpdate);
|
||||
|
||||
if (notificationResult != DialogResult.Yes) return;
|
||||
|
||||
try
|
||||
{
|
||||
Serilog.Log.Logger.Information("Start upgrade. {@DebugInfo}", new { CurrentlyInstalled = args.InstalledVersion, TargetVersion = args.CurrentVersion });
|
||||
AutoUpdater.DownloadUpdate(args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBoxLib.ShowAdminAlert(null, "Error downloading update", "Error downloading update", ex);
|
||||
}
|
||||
}
|
||||
|
||||
AutoUpdater.CheckForUpdateEvent += AutoUpdaterOnCheckForUpdateEvent;
|
||||
AutoUpdater.Start(LibationScaffolding.RepositoryLatestUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,13 +11,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@ -11,13 +11,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@ -6,7 +6,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>..\..\bin\Publish\classic</PublishDir>
|
||||
<PublishDir>C:\Users\mbuca\OneDrive\Projects\Libation\Source\bin\Publish\Windows-chardonnay</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
|
||||
@ -7,19 +7,12 @@
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<PublishReadyToRun>true</PublishReadyToRun>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
HACK FOR COMPILER BUG 2021-09-14. Hopefully will be fixed in future versions
|
||||
- Not using SatelliteResourceLanguages will load all language packs: works
|
||||
- Specifying 'en' semicolon 1 more should load 1 language pack: works
|
||||
- Specifying only 'en' should load no language packs: broken, still loads all
|
||||
-->
|
||||
<SatelliteResourceLanguages>en;es</SatelliteResourceLanguages>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user