-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdater.cs
More file actions
35 lines (29 loc) · 1.02 KB
/
Updater.cs
File metadata and controls
35 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
namespace SystemGameManager.Service;
using Velopack;
using Velopack.Sources;
using System;
using System.Threading.Tasks;
public class Updater
{
public async Task AutoUpdate()
{
try
{
var repoUrl = GlobalConfig.Settings.AppConfig.RepositoryUrl;
var source = new GithubSource(repoUrl, null, true);
var mgr = new UpdateManager(source);
if (!mgr.IsInstalled)
return;
var update = await mgr.CheckForUpdatesAsync();
if (update == null)
return;
await mgr.DownloadUpdatesAsync(update);
mgr.ApplyUpdatesAndRestart(update);
}
catch (Exception ex)
{
ConsoleError($"Fehler beim automatischen Update: {ex.Message}");
System.Windows.Forms.MessageBox.Show($"Ein Fehler ist beim automatischen Update aufgetreten:\n\n{ex.Message}", "Update-Fehler", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
}
}