From: AeonLucid Date: Thu, 12 Nov 2020 01:59:50 +0000 (+0100) Subject: Print out version on startup X-Git-Tag: v1.2.2~35 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=57cce72df592084fb2829afd00e826b1f183c6b5;p=rhonda%2Fimpostor.git Print out version on startup --- 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; + } + } +}