From 60df0ea0ae60dc6130dbdad58f2e7e020953da32 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 4 Jul 2024 18:07:49 +1000 Subject: [PATCH] WIP on dotnet update support --- CLI/Program.cs | 13 +++++++++++-- MCGalaxy/Server/Maintenance/Updater.cs | 14 ++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CLI/Program.cs b/CLI/Program.cs index 41d03b8a9..0bdc76fc7 100644 --- a/CLI/Program.cs +++ b/CLI/Program.cs @@ -31,8 +31,9 @@ public static void Main(string[] args) { // If MCGalaxy_.dll is missing, a FileNotFoundException will get thrown for MCGalaxy dll try { EnableCLIMode(); - } catch (FileNotFoundException) { - Console.WriteLine("Cannot start server as MCGalaxy_.dll is missing from " + Environment.CurrentDirectory); + } catch (FileNotFoundException ex) { + Console.WriteLine("Cannot start server as {0} is missing from {1}", + GetFilename(ex.FileName), Environment.CurrentDirectory); Console.WriteLine("Download from " + Updater.UploadsURL); Console.WriteLine("Press any key to exit..."); Console.ReadKey(true); @@ -43,6 +44,14 @@ public static void Main(string[] args) { StartCLI(); } + static string GetFilename(string rawName) { + try { + return new AssemblyName(rawName).Name + ".dll"; + } catch { + return rawName; + } + } + static void SetCurrentDirectory() { #if !MCG_STANDALONE string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); diff --git a/MCGalaxy/Server/Maintenance/Updater.cs b/MCGalaxy/Server/Maintenance/Updater.cs index 46e42ca8b..eccd7e7a4 100644 --- a/MCGalaxy/Server/Maintenance/Updater.cs +++ b/MCGalaxy/Server/Maintenance/Updater.cs @@ -33,7 +33,11 @@ public static class Updater const string changelogURL = BaseURL + "Changelog.txt"; const string CDN_URL = "https://cdn.classicube.net/client/mcg/{0}/"; -#if NET_20 +#if NET8_0 + const string CDN_BASE = CDN_URL + "net80/"; +#elif NET6_0 + const string CDN_BASE = CDN_URL + "net60/"; +#elif NET_20 const string CDN_BASE = CDN_URL + "net20/"; #else const string CDN_BASE = CDN_URL + "net40/"; @@ -90,11 +94,13 @@ public static void PerformUpdate(bool release) { } string mode = release ? "release" : "latest"; - Logger.Log(LogType.SystemActivity, "Downloading {0} update files", mode); - + Logger.Log(LogType.SystemActivity, "Downloading {0} update files", mode); WebClient client = HttpUtil.CreateWebClient(); + client.DownloadFile(DLL_URL.Replace("{0}", mode), "MCGalaxy_.update"); -#if !MCG_STANDALONE +#if MCG_DOTNET + client.DownloadFile(CLI_URL.Replace("{0}", mode), "MCGalaxyCLI.update"); +#elif !MCG_STANDALONE client.DownloadFile(GUI_URL.Replace("{0}", mode), "MCGalaxy.update"); client.DownloadFile(CLI_URL.Replace("{0}", mode), "MCGalaxyCLI.update"); #endif