]> git.deb.at Git - rhonda/impostor.git/commitdiff
Fix path issue
authorAeonLucid <aeonlucid@outlook.com>
Thu, 5 Nov 2020 03:38:06 +0000 (04:38 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Thu, 5 Nov 2020 03:38:06 +0000 (04:38 +0100)
src/Impostor.Server/Plugins/PluginLoader.cs
src/Impostor.Server/Program.cs
src/Impostor.Server/Utils/DirUtils.cs [deleted file]

index 1ea207203d3498f3b560d9c67ffae40c1a01d270..4e728868f3bc628b52e8c77a0cc34c01ac46e9d3 100644 (file)
@@ -26,7 +26,7 @@ namespace Impostor.Server.Plugins
             var pluginPaths = new List<string>(config.Paths);
             var libraryPaths = new List<string>(config.LibraryPaths);
 
-            var rootFolder = DirUtils.GetExecutableDirectory();
+            var rootFolder = Directory.GetCurrentDirectory();
 
             pluginPaths.Add(Path.Combine(rootFolder, "plugins"));
             libraryPaths.Add(Path.Combine(rootFolder, "libraries"));
index 361a671401e9c9ec75e4245414353b1f2bc028c3..dc158e57fe0498764b5ea141060e41093e4bff6d 100644 (file)
@@ -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<PluginConfig>() ?? 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 (file)
index 0d1c7d9..0000000
+++ /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;
-        }
-    }
-}