Files
PCK-Studio/PCK-Studio-Updater/Program.cs
Miku-666 1e94d23281 Added new PCK-Studio Updater (#20)
* Added PCK-Studio-Updater project

* Updated PCK-Studio-Updater to be a standanlone executable and added checkbox for using beta builds in the settings panel

* Rename constant define '_NOT_DEBUG' to 'NDEBUG' and moved it to .csproj file
2023-10-08 15:00:01 +02:00

59 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Text;
using System.Text.RegularExpressions;
namespace PCKStudio_Updater
{
internal class Program
{
static void Main(string[] args)
{
Uri projectUrl = new Uri("https://github.com/PhoenixARC/-PCK-Studio");
if (args.Length > 0)
{
projectUrl = new Uri(args[0]);
}
string executableName = "PCK-Studio";
if (args.Length > 1)
{
executableName = args[1];
}
bool prerelease = false;
if (args.Length > 2)
{
prerelease = args[2].ToLower() == "true" || args[2].ToLower() == "1";
}
var versionMatcher = new Regex("(\\*|\\d+(\\.\\d+){0,3}(\\.\\*)?)");
if (args.Length > 3)
{
versionMatcher = new Regex(args[3]);
}
GithubParams updateParams = new GithubParams(
Path.GetDirectoryName(projectUrl.AbsolutePath).Replace("\\", ""),
Path.GetFileName(projectUrl.AbsolutePath),
executableName,
prerelease,
versionMatcher
);
IUpdateDownloader updater = new GithubUpdateDownloader(updateParams);
if (!File.Exists(updateParams.TargetExecutableName + ".exe") || updater.IsUpdateAvailable(FileVersionInfo.GetVersionInfo(updateParams.TargetExecutableName + ".exe").ProductVersion))
{
updater.DownloadTo(new DirectoryInfo("."));
updater.Launch();
return;
}
}
}
}