Files
PCL-ISE/tests/Check-LauncherRelease.cs
T
Coldsmile_7 3ef14b65fe
Build / Build (Debug) (push) Canceled after 0s
Build / Build (Release) (push) Canceled after 0s
feat: prepare PCL-ISE 0.1.1 update test release
2026-10-25 22:59:27 +08:00

43 lines
2.2 KiB
C#

using System;
using System.IO;
using System.Reflection;
using System.Security.Cryptography;
// Run under .NET Framework after compiling with the framework's csc.exe.
// Uses the launcher's real release API parser without starting its main window.
internal static class CheckLauncherRelease {
[STAThread]
private static int Main(string[] args) {
try {
Assembly launcher = Assembly.LoadFrom(Path.GetFullPath(args[0]));
Activator.CreateInstance(launcher.GetType("PCL.Application", true), true);
Assembly core = Assembly.Load("MeloongCore");
core.GetType("MeloongCore.Main", true).GetMethod("Init").Invoke(null, new object[] { "PCL" });
Type module = launcher.GetType("PCL.ModSecret", true);
object info = module.GetMethod("GetLatestLauncherUpdate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null);
Type infoType = info.GetType();
string tag = (string)infoType.GetField("TagName").GetValue(info);
string hash = (string)infoType.GetField("AssetHash").GetValue(info);
string url = (string)infoType.GetField("DownloadUrl").GetValue(info);
string version = infoType.GetField("VersionNumber").GetValue(info).ToString();
Console.WriteLine("Release: " + tag + ", version: " + version);
Console.WriteLine("Asset: " + url);
Console.WriteLine("SHA256: " + hash);
if (args.Length > 1) {
using (SHA256 sha = SHA256.Create())
using (Stream file = File.OpenRead(args[1])) {
string expected = BitConverter.ToString(sha.ComputeHash(file)).Replace("-", "");
if (!expected.Equals(hash, StringComparison.OrdinalIgnoreCase))
throw new InvalidDataException("Release SHA256 does not match local build");
}
}
if (tag != "v0.1.1" || version != "0.1.1.0") throw new InvalidDataException("Unexpected test release version");
Console.WriteLine("PASS: launcher resolves published test release and checksum");
return 0;
} catch (Exception ex) {
Console.Error.WriteLine(ex.ToString());
return 1;
}
}
}