Moved ChangelogHelper and MarkdownSharp.cs to Katteker Lib, polish up the Gui.

This commit is contained in:
Holger Börchers 2018-03-23 14:07:24 +01:00
parent 6fafdd3090
commit 54979f9a69
14 changed files with 128 additions and 173 deletions

View File

@ -8,7 +8,7 @@
Title="MainWindow"
Width="800"
Height="450"
Background="BlueViolet"
Background="Chartreuse"
ContentRendered="MainWindow_OnContentRendered"
mc:Ignorable="d">
<StackPanel>

View File

@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.42")]
[assembly: AssemblyFileVersion("1.0.42")]
[assembly: AssemblyVersion("1.0.48")]
[assembly: AssemblyFileVersion("1.0.48")]

View File

@ -42,8 +42,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChangelogHelper.cs" />
<Compile Include="MarkdownSharp.cs" />
<Compile Include="Wrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">

View File

@ -60,6 +60,15 @@ namespace Katteker.Gui.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Could not update your application..
/// </summary>
internal static string CouldNotUpdateYourApplication {
get {
return ResourceManager.GetString("CouldNotUpdateYourApplication", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Installed new Version! Would you like to restart the Application?.
/// </summary>
@ -123,6 +132,15 @@ namespace Katteker.Gui.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Updater.
/// </summary>
internal static string Updater {
get {
return ResourceManager.GetString("Updater", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You can update to Version: .
/// </summary>

View File

@ -144,4 +144,10 @@
<data name="SquirrelWrapper_CheckForUpdate_AskYourLocalDistributor" xml:space="preserve">
<value> Ask your local distributor.</value>
</data>
<data name="Updater" xml:space="preserve">
<value>Updater</value>
</data>
<data name="CouldNotUpdateYourApplication" xml:space="preserve">
<value>Could not update your application.</value>
</data>
</root>

View File

@ -21,7 +21,6 @@ namespace Katteker.Gui
[STAThread]
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UpdateWindow));
this.mainSplitContainer = new System.Windows.Forms.SplitContainer();
this.titleLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.closeWindowBtn = new System.Windows.Forms.Button();
@ -85,6 +84,7 @@ namespace Katteker.Gui
this.titleLayoutPanel.Controls.Add(this.minimizeBtn, 2, 0);
this.titleLayoutPanel.Controls.Add(this.label1, 0, 0);
this.titleLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.titleLayoutPanel.ForeColor = System.Drawing.SystemColors.Control;
this.titleLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.titleLayoutPanel.Name = "titleLayoutPanel";
this.titleLayoutPanel.RowCount = 1;
@ -101,7 +101,6 @@ namespace Katteker.Gui
this.closeWindowBtn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Red;
this.closeWindowBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.closeWindowBtn.Font = new System.Drawing.Font("Segoe UI Symbol", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.closeWindowBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.closeWindowBtn.Location = new System.Drawing.Point(658, 0);
this.closeWindowBtn.Margin = new System.Windows.Forms.Padding(0);
this.closeWindowBtn.Name = "closeWindowBtn";
@ -118,7 +117,6 @@ namespace Katteker.Gui
this.maximizeBtn.FlatAppearance.BorderSize = 0;
this.maximizeBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.maximizeBtn.Font = new System.Drawing.Font("Segoe UI Symbol", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.maximizeBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.maximizeBtn.Location = new System.Drawing.Point(618, 0);
this.maximizeBtn.Margin = new System.Windows.Forms.Padding(0);
this.maximizeBtn.Name = "maximizeBtn";
@ -133,12 +131,11 @@ namespace Katteker.Gui
//
this.titlebar.Dock = System.Windows.Forms.DockStyle.Fill;
this.titlebar.Font = new System.Drawing.Font("Segoe UI", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.titlebar.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.titlebar.Location = new System.Drawing.Point(123, 0);
this.titlebar.Name = "titlebar";
this.titlebar.Size = new System.Drawing.Size(452, 30);
this.titlebar.TabIndex = 0;
this.titlebar.Text = "titleBar";
this.titlebar.Text = "Updater";
this.titlebar.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.titlebar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Titlebar_MouseDown);
//
@ -148,7 +145,6 @@ namespace Katteker.Gui
this.minimizeBtn.FlatAppearance.BorderSize = 0;
this.minimizeBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.minimizeBtn.Font = new System.Drawing.Font("Segoe UI Symbol", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.minimizeBtn.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.minimizeBtn.Location = new System.Drawing.Point(578, 0);
this.minimizeBtn.Margin = new System.Windows.Forms.Padding(0);
this.minimizeBtn.Name = "minimizeBtn";
@ -163,7 +159,6 @@ namespace Katteker.Gui
//
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("Segoe UI Symbol", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.Window;
this.label1.Location = new System.Drawing.Point(3, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(114, 30);
@ -276,11 +271,13 @@ namespace Katteker.Gui
this.DoubleBuffered = true;
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "UpdateWindow";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Activated += new System.EventHandler(this.UpdateWindow_Activated);
this.Deactivate += new System.EventHandler(this.UpdateWindow_Deactivate);
this.Load += new System.EventHandler(this.UpdateWindow_Load);
this.mainSplitContainer.Panel1.ResumeLayout(false);
this.mainSplitContainer.Panel2.ResumeLayout(false);

View File

@ -8,14 +8,18 @@ namespace Katteker.Gui
{
public sealed partial class UpdateWindow : Form
{
private readonly UpdateManager _updateManager;
private readonly ReleaseEntry _entry;
private const int HTCAPTION = 0x2;
private const int WM_NCLBUTTONDOWN = 0xA1;
/// <summary>
/// The Update Window
/// </summary>
public UpdateWindow()
public UpdateWindow(UpdateManager updateManager, ReleaseEntry entry)
{
_updateManager = updateManager;
_entry = entry;
Font = SystemFonts.MessageBoxFont;
Application.EnableVisualStyles();
if (Environment.OSVersion.Version.Major >= 6)
@ -23,19 +27,9 @@ namespace Katteker.Gui
InitializeComponent();
}
private string Changelog => UpdateManager.ChangelogFilename;
/// <summary>
/// Last release entry.
/// </summary>
public ReleaseEntry ReleaseEntry { get; set; }
private string Changelog => _updateManager.ChangelogFilename;
/// <summary>
/// Update manager
/// </summary>
public UpdateManager UpdateManager { get; set; }
private string PublishPath => UpdateManager.UrlOrPath;
private string PublishPath => _updateManager.UrlOrPath;
/// <inheritdoc />
/// <summary>
@ -76,22 +70,40 @@ namespace Katteker.Gui
private void Titlebar_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && e.Clicks >= 2)
{
MaximizeBtn_Click(sender, e);
return;
}
if (e.Button != MouseButtons.Left) return;
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
private void UpdateWindow_Activated(object sender, EventArgs e)
{
titleLayoutPanel.BackColor = SystemColors.ControlDarkDark;
titleLayoutPanel.ForeColor = SystemColors.Control;
}
private void UpdateWindow_Deactivate(object sender, EventArgs e)
{
titleLayoutPanel.BackColor = SystemColors.Control;
titleLayoutPanel.ForeColor = SystemColors.ControlText;
}
private async void UpdateWindow_Load(object sender, EventArgs e)
{
var changelog = await ChangelogHelper.LoadChangelogAsync(Changelog, PublishPath).ConfigureAwait(false);
Invoke(new Action(() => changelogBrowser.DocumentText = changelog));
if (ReleaseEntry == null)
if (_entry == null)
{
Invoke(new Action(() => { WriteTitle(Resources.No_update_available); }));
}
else
{
var latest = ReleaseEntry.Version;
var latest = _entry.Version;
Invoke(new Action(() =>
{
WriteTitle(Resources.You_can_update_to_Version + latest);
@ -107,13 +119,25 @@ namespace Katteker.Gui
try
{
var progress = new Progress<int>(x => Invoke(new Action(() => { progressBar1.Value = x; })));
await UpdateManager.UpdateAppAsync(progress).ConfigureAwait(false);
await _updateManager.UpdateAppAsync(progress).ConfigureAwait(false);
WriteTitle(Resources.You_re_up_to_date);
var messResult = MessageBox.Show(
Resources.Installed_new_Version,
Resources.New_Version,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (messResult == DialogResult.Yes)
{
DialogResult = DialogResult.OK;
Close();
}
}
catch (Exception ex)
{
WriteTitle(ex.Message);
MessageBox.Show(Resources.CouldNotUpdateYourApplication + Environment.NewLine + ex.Message, Gui.Properties.Resources.Updater, MessageBoxButtons.OK, MessageBoxIcon.Error);
WriteTitle(Resources.Updater);
}
finally
{
@ -121,19 +145,10 @@ namespace Katteker.Gui
{
progressBar1.Visible = false;
updBtn.Visible = false;
var messResult = MessageBox.Show(
Resources.Installed_new_Version,
Resources.New_Version,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (messResult == DialogResult.Yes)
{
DialogResult = DialogResult.OK;
Close();
}
}));
}
}
private void WriteTitle(string text)
{
Invoke(new Action(() =>

View File

@ -117,81 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABYYGwFCSVQrTlloXjZEUYFIV2iiUmqFt1h2
m8o1UHHcEShHPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhgcBiQuPs5khK7/fajd/3up
4P94q+b/fa3p/0Jml/8NIkVQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEB80eUdy
qv9+rOj/eqfg/3Sk3f96p+D/SG2f/xMZKWMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAMGS45OWCR/1yOzf9Gdar/SXyr/0uBtP85bqT/IUBk3ilBU2JzhZUaAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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IOVv7Dj7f/f////XHF4/yki
Yv8vK2L/LS5m/ykjVP+yr7X//////5yan/+Mk5T/mqWq/3qMlP95lKL/gZqp/32Po/9JVWn/ZG9u/837
/P/S////hay3/7i5lVEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHiOkn2YwtT/2////8fm
6v85Q1//Ni15/zYzeP8yMX7/KiNe/0pMUv+To5n/k6+2/7vc3v+339f/xPXv/9r////Z////2f///6DG
w/+22d7/2v///8X4/f9ehZvPubuYAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACYnpg7apO398//
///T////p8bM/y8sX/8/MH3/NTBx/zAmXP9bZHv/psbK/8z4+f/Y////jau2/3B7ov98gqf/hZWd/7/m
4f/a////xe30/8L7/f/a////eqfG/3WEk4EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGR3
lbWw5/L/0v///9P///+Jp67/Lydl/zgubP8xOFv/kKmx/9T++//N////1v///6S8wf97d6r/trD//7Wv
//+gm+H/X3GM/7DY3v/N/Pn/1////4691/9Nboa3xMKtBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALTF
mw2Ln5NQfqPD/9P////N+f//2f///3WKlP8rImH/Nz5m/6zN0P/a////yfv//8z7///N9uj/cn6d/7Wx
+v+srPj/n5ve/3t3ov9JWoD/W4i0/2aax/9chrf/UnKM1K64lRoAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAmpuYUnOEmKuv3+n/z/7//8z8/P/a////b3iN/yYpS/+iw87/1////8z8/P/O/P3/2P///5i9
0P9SXoT/doOz/19rkf9IS2D/Z2ls/5GWnP91gpr/ZJDE/0hytf+KlYiDAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABje5eGbY6k2cX9/v/P/f//yfj7/5/Awv8+SVL/bH2B/+D////J+f//0f///8Pz
+v9smLD/Pl59/2Jmdv9ecZT/ZX6f/6Ouuf////////////r49P+RoKv/UXiw/159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AAAAAAAAAAAAAAAAAAAAAAAAAAAJadk0xUgLX/cp3a/3Wh2v9ReqLWcHuVBwAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtr+jJENtlehZjdH/VH22/3uU
l38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAg6KaP3KG
jb2MnJd0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA/wB///8Af///gH///4Af//+AA///AAD//gAAf/4AAD/8AAAf+AAAD/AA
AA/wAAAP4AAAH+AAAB+AAAA/gAAAf4AAAH+AAAB/gAAAP4AAAD/AAAAH8AAAA/gAAAH/gAAB/4ABgf/A
A///wA///8H////A////wP///8H////j//8=
</value>
</data>
</root>

View File

@ -1,4 +1,5 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Katteker.Gui.Properties;
@ -10,6 +11,8 @@ namespace Katteker.Gui
/// </summary>
public static class Wrapper
{
private static UpdateManager _manager;
/// <summary>
/// Checks for Updates.
/// </summary>
@ -23,38 +26,36 @@ namespace Katteker.Gui
/// <returns>Task</returns>
public static async Task CheckForUpdateAsync(bool isStartup)
{
using (var window = new UpdateWindow())
if (_manager == null && !UpdateManager.TryCreate(out _manager))
{
var dialogResult = DialogResult.Cancel;
if (!UpdateManager.TryCreate(out var manager))
if (!isStartup)
{
if (!isStartup)
{
MessageBox.Show(Resources.SquirrelWrapper_CheckForUpdate,
Resources.SquirrelWrapper_CheckForUpdate_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return;
MessageBox.Show(Resources.SquirrelWrapper_CheckForUpdate,
Resources.SquirrelWrapper_CheckForUpdate_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
var releases = (await manager.CheckForUpdateAsync().ConfigureAwait(true)).ToArray();
window.UpdateManager = manager;
window.ReleaseEntry = releases.LastOrDefault();
if (isStartup)
{
if (releases?.Any() == true)
{
dialogResult = window.ShowDialog();
}
}
else
{
dialogResult = window.ShowDialog();
}
return;
}
var releases = (await _manager.CheckForUpdateAsync().ConfigureAwait(false)).ToArray();
if (releases.Any() || !isStartup)
{
var thread = new Thread(ThreadProcess);
thread.SetApartmentState(ApartmentState.STA);
thread.Start(releases.LastOrDefault());
thread.Join();
}
}
private static void ThreadProcess(object argument)
{
var entry = (ReleaseEntry) argument;
using (var window = new UpdateWindow(_manager, entry))
{
var dialogResult = window.ShowDialog();
if (dialogResult == DialogResult.OK)
{
manager.RestartApp();
_manager.RestartApp();
}
}
}

View File

@ -3,9 +3,9 @@ using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace Katteker.Gui
namespace Katteker
{
internal static class ChangelogHelper
public static class ChangelogHelper
{
private static string GenerateChangelogAsHtml(string text, string extension)
{
@ -27,7 +27,7 @@ namespace Katteker.Gui
return result;
}
internal static async Task<string> LoadChangelogAsync(string filename, string path)
public static async Task<string> LoadChangelogAsync(string filename, string path)
{
if (!string.IsNullOrEmpty(filename) || !string.IsNullOrEmpty(path))
{

View File

@ -38,8 +38,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ChangelogHelper.cs" />
<Compile Include="Constants.cs" />
<Compile Include="KattekerConfig.cs" />
<Compile Include="MarkdownSharp.cs" />
<Compile Include="SemanticVersion.cs" />
<Compile Include="UpdateInfo.cs" />
<Compile Include="UpdateManager.cs" />

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyVersion("1.0.2")]
[assembly: AssemblyFileVersion("1.0.2")]

View File

@ -80,6 +80,7 @@ namespace Katteker
return false;
}
}
public async Task<IEnumerable<ReleaseEntry>> CheckForUpdateAsync()
{
_releases = Utility.IsWebUrl(_urlOrPath) ? await DownloadIndexAsync(_urlOrPath).ConfigureAwait(false) : GetFromFilesystem(_urlOrPath);
@ -124,7 +125,7 @@ namespace Katteker
var url = urlOrPath.TrimEnd('/');
url += "/" + Constants.RELEASE;
var content = await new WebClient().DownloadStringTaskAsync(url).ConfigureAwait(false);
var lines = content.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
var lines = content.Split(new[] {'\r', '\n'}, StringSplitOptions.RemoveEmptyEntries);
return new Releases(lines);
}
@ -136,6 +137,7 @@ namespace Katteker
if (!File.Exists(configPath)) throw new FileNotFoundException("Configuration file not found.", configPath);
return KattekerConfig.ReadFromFile(configPath);
}
private static bool VerifyFileChecksum(string targetFile, string lastEntrySha1)
{
var hash = Utility.ComputeFileHash(targetFile);
@ -175,35 +177,28 @@ namespace Katteker
private async Task<bool> UpdateAppImplAsync(ReleaseEntry lastEntry, IProgress<int> progress)
{
try
var targetFile = Path.Combine(_packageDir, lastEntry.Filename);
//download file.
await PutFileInPackageFolderAsync(lastEntry.Filename).ConfigureAwait(false);
progress?.Report(60);
if (!VerifyFileChecksum(targetFile, lastEntry.SHA1)) throw new FileLoadException();
progress?.Report(70);
await KillAppStubAsync().ConfigureAwait(false);
progress?.Report(80);
using (var updater = new Process())
{
var targetFile = Path.Combine(_packageDir, lastEntry.Filename);
//download file.
await PutFileInPackageFolderAsync(lastEntry.Filename).ConfigureAwait(false);
progress?.Report(60);
if (!VerifyFileChecksum(targetFile, lastEntry.SHA1)) throw new FileLoadException();
progress?.Report(70);
await KillAppStubAsync().ConfigureAwait(false);
progress?.Report(80);
using (var updater = new Process())
{
updater.StartInfo = new ProcessStartInfo(targetFile, "/S");
updater.Start();
updater.WaitForExit();
}
progress?.Report(100);
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
updater.StartInfo = new ProcessStartInfo(targetFile, "/S");
updater.Start();
updater.WaitForExit();
}
return false;
progress?.Report(100);
return true;
}
}
}