]> git.deb.at Git - rhonda/impostor.git/commitdiff
Print out version on startup
authorAeonLucid <aeonlucid@outlook.com>
Thu, 12 Nov 2020 01:59:50 +0000 (02:59 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Thu, 12 Nov 2020 01:59:50 +0000 (02:59 +0100)
src/Impostor.Server/Program.cs
src/Impostor.Server/Utils/DotnetUtils.cs [new file with mode: 0644]

index 57c1c523fe2ea7f57a0fcbd47e54a5e3ed1db7a8..5c0d6eb767c04b45ea1ec17fb77f0437dd7fad67 100644 (file)
@@ -1,8 +1,5 @@
 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;
@@ -46,10 +43,7 @@ namespace Impostor.Server
 
             try
             {
-                // var assembly = Assembly.GetExecutingAssembly();
-                // var fileVersion = FileVersionInfo.GetVersionInfo(assembly.Location);
-
-                Log.Information("Starting Impostor"); // v{0}", fileVersion.ProductVersion);
+                Log.Information("Starting Impostor v{0}", DotnetUtils.GetVersion());
                 CreateHostBuilder(args).Build().Run();
                 return 0;
             }
diff --git a/src/Impostor.Server/Utils/DotnetUtils.cs b/src/Impostor.Server/Utils/DotnetUtils.cs
new file mode 100644 (file)
index 0000000..48a0ac0
--- /dev/null
@@ -0,0 +1,20 @@
+using System.Reflection;
+
+namespace Impostor.Server.Utils
+{
+    internal static class DotnetUtils
+    {
+        private const string DefaultUnknownBuild = "UNKNOWN";
+
+        public static string GetVersion()
+        {
+            var attribute = typeof(DotnetUtils).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
+            if (attribute != null)
+            {
+                return attribute.InformationalVersion;
+            }
+
+            return DefaultUnknownBuild;
+        }
+    }
+}