From: AeonLucid Date: Thu, 5 Nov 2020 03:38:06 +0000 (+0100) Subject: Fix path issue X-Git-Tag: v1.2.2~39 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=b7bbcfdc2cbf33aae6e617f1b35e8bf5b1094002;p=rhonda%2Fimpostor.git Fix path issue --- diff --git a/src/Impostor.Server/Plugins/PluginLoader.cs b/src/Impostor.Server/Plugins/PluginLoader.cs index 1ea2072..4e72886 100644 --- a/src/Impostor.Server/Plugins/PluginLoader.cs +++ b/src/Impostor.Server/Plugins/PluginLoader.cs @@ -26,7 +26,7 @@ namespace Impostor.Server.Plugins var pluginPaths = new List(config.Paths); var libraryPaths = new List(config.LibraryPaths); - var rootFolder = DirUtils.GetExecutableDirectory(); + var rootFolder = Directory.GetCurrentDirectory(); pluginPaths.Add(Path.Combine(rootFolder, "plugins")); libraryPaths.Add(Path.Combine(rootFolder, "libraries")); diff --git a/src/Impostor.Server/Program.cs b/src/Impostor.Server/Program.cs index 361a671..dc158e5 100644 --- a/src/Impostor.Server/Program.cs +++ b/src/Impostor.Server/Program.cs @@ -1,4 +1,8 @@ using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; using Impostor.Api.Events.Managers; using Impostor.Api.Games; using Impostor.Api.Games.Managers; @@ -34,7 +38,7 @@ namespace Impostor.Server .MinimumLevel.Override("Microsoft", LogEventLevel.Debug) #else .MinimumLevel.Information() - .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) #endif .Enrich.FromLogContext() .WriteTo.Console() @@ -42,7 +46,10 @@ namespace Impostor.Server try { - Log.Information("Starting Impostor"); + var assembly = Assembly.GetExecutingAssembly(); + var fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location); + + Log.Information("Starting Impostor v{0}", fileVersion.ProductVersion); CreateHostBuilder(args).Build().Run(); return 0; } @@ -76,7 +83,7 @@ namespace Impostor.Server .Get() ?? new PluginConfig(); return Host.CreateDefaultBuilder(args) - .UseContentRoot(DirUtils.GetExecutableDirectory()) + .UseContentRoot(Directory.GetCurrentDirectory()) #if DEBUG .UseEnvironment(Environment.GetEnvironmentVariable("IMPOSTOR_ENV") ?? "Development") #else diff --git a/src/Impostor.Server/Utils/DirUtils.cs b/src/Impostor.Server/Utils/DirUtils.cs deleted file mode 100644 index 0d1c7d9..0000000 --- a/src/Impostor.Server/Utils/DirUtils.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Diagnostics; -using System.IO; - -namespace Impostor.Server.Utils -{ - internal static class DirUtils - { - // Workaround for: - // - https://github.com/dotnet/runtime/issues/40828 - // - https://github.com/dotnet/runtime/issues/38405#issuecomment-652643506 - public static string GetExecutableDirectory() - { - var programDirectory = Path.GetDirectoryName(typeof(Program).Assembly.Location)!; - var currentDirectory = Directory.GetCurrentDirectory(); - var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - var executablePath = Process.GetCurrentProcess().MainModule!.FileName; - var executableDirectory = Path.GetDirectoryName(executablePath)!; - var executable = Path.GetFileNameWithoutExtension(executablePath); - - if ("dotnet".Equals(executable, StringComparison.InvariantCultureIgnoreCase)) - { - return programDirectory; - } - - return executableDirectory; - } - } -}