Skip to content

Commit

Permalink
WIP on dotnet update support
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jul 4, 2024
1 parent 3c2d98c commit 60df0ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 11 additions & 2 deletions CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public static class Program {
// 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);
Expand All @@ -43,6 +44,14 @@ public static class Program {
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);

Check warning on line 57 in CLI/Program.cs

View workflow job for this annotation

GitHub Actions / build-dotnet6

'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.

Check warning on line 57 in CLI/Program.cs

View workflow job for this annotation

GitHub Actions / build-dotnet8

'System.Reflection.Assembly.Location' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
Expand Down
14 changes: 10 additions & 4 deletions MCGalaxy/Server/Maintenance/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down Expand Up @@ -90,11 +94,13 @@ public static class Updater
}

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
Expand Down

0 comments on commit 60df0ea

Please sign in to comment.