mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 16:36:27 +00:00
* 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
59 lines
1.8 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|