Skip to content

Commit

Permalink
Again try to fix updating not working in standalone build
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed May 3, 2024
1 parent 2aa4cd1 commit 1b6c090
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public static class Program {
} catch {
// in case user is running CLI with older MCGalaxy dll which lacked CLIMode field
}

#if !MCG_STANDALONE
Server.RestartPath = Assembly.GetEntryAssembly().Location;

Check warning on line 70 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 70 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 70 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'.

Check warning on line 70 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'.
#endif
}


Expand Down
17 changes: 8 additions & 9 deletions MCGalaxy/Server/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,17 @@ public sealed partial class Server


public static string GetServerDLLPath() {
#if MCG_STANDALONE
return GetRuntimeProcessExePath();
#else
return Assembly.GetExecutingAssembly().Location;
#endif
}

public static string GetRestartPath() {
#if !NETSTANDARD
#if MCG_STANDALONE
return GetRuntimeProcessExePath();
#elif !NETSTANDARD
return RestartPath;
#else
// NET core/5/6 executables tend to use the following structure:
Expand All @@ -273,14 +279,7 @@ public sealed partial class Server
// is actually the managed assembly, but we need to remove '.dll'
// as the actual executable which must be started is the non .dll file
string path = RestartPath;
if (path.CaselessEnds(".dll")) path = path.Substring(0, path.Length - 4);

#if MCG_STANDALONE
// Server.RestartPath is empty in self contained builds
// TODO maybe move this elsewhere?
if (string.IsNullOrEmpty(path)) path = GetRuntimeProcessExePath();
#endif

if (path.CaselessEnds(".dll")) path = path.Substring(0, path.Length - 4);
return path;
#endif
}
Expand Down

0 comments on commit 1b6c090

Please sign in to comment.