Migrate update system to XML manifest and improve multi-OS support

This commit is contained in:
Stone_Red
2026-02-20 20:05:33 +01:00
parent e7102ab0b3
commit dd0d24cf47
5 changed files with 278 additions and 129 deletions
@@ -3,8 +3,8 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>AlwaysUpToDate_Test</RootNamespace>
<StartupObject>AlwaysUpToDate_Test.Program</StartupObject>
<RootNamespace>AlwaysUpToDate.Test</RootNamespace>
<StartupObject>AlwaysUpToDate.Test.Program</StartupObject>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0.0</FileVersion>
<PackageTags></PackageTags>
+54
View File
@@ -0,0 +1,54 @@
using System;
using System.Threading.Tasks;
namespace AlwaysUpToDate.Test;
internal class Program
{
private static readonly Updater updater = new Updater(new TimeSpan(0, 0, 1), "https://raw.githubusercontent.com/Stone-Red-Code/Test/main/test.xml", true);
private static async Task Main(string[] args)
{
updater.ProgressChanged += Updater_ProgressChanged;
updater.UpdateAvailable += Updater_UpdateAvailable;
updater.NoUpdateAvailable += Updater_NoUpdateAvailable;
updater.OnException += Updater_OnException;
updater.Start();
await Task.Delay(-1);
}
private static async void Updater_UpdateAvailable(string version, string changelogUrl)
{
updater.Stop();
Console.WriteLine("New Update available: " + version);
if (!string.IsNullOrEmpty(changelogUrl))
{
Console.WriteLine("Changelog: " + changelogUrl);
}
Console.WriteLine("Do you want to install the new update? (y/n)");
char input = Console.ReadKey().KeyChar;
if (char.ToLower(input) == 'y')
{
await updater.Update();
}
}
private static void Updater_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage)
{
Console.WriteLine($"{totalBytesDownloaded}/{totalFileSize} {progressPercentage}%");
}
private static void Updater_NoUpdateAvailable()
{
Console.WriteLine("You are up to date!");
}
private static void Updater_OnException(Exception exception)
{
Console.WriteLine(exception.ToString());
}
}