From 57cce72df592084fb2829afd00e826b1f183c6b5 Mon Sep 17 00:00:00 2001 From: AeonLucid Date: Thu, 12 Nov 2020 02:59:50 +0100 Subject: [PATCH] Print out version on startup --- src/Impostor.Server/Program.cs | 8 +------- src/Impostor.Server/Utils/DotnetUtils.cs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 src/Impostor.Server/Utils/DotnetUtils.cs diff --git a/src/Impostor.Server/Program.cs b/src/Impostor.Server/Program.cs index 57c1c52..5c0d6eb 100644 --- a/src/Impostor.Server/Program.cs +++ b/src/Impostor.Server/Program.cs @@ -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 index 0000000..48a0ac0 --- /dev/null +++ b/src/Impostor.Server/Utils/DotnetUtils.cs @@ -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(); + if (attribute != null) + { + return attribute.InformationalVersion; + } + + return DefaultUnknownBuild; + } + } +} -- 2.39.5