From f905b17b3a4116e5c657023d4e087f12271b789f Mon Sep 17 00:00:00 2001 From: Marius Nechifor Date: Wed, 1 Jan 2025 17:09:06 +0200 Subject: [PATCH] Add app version logging on startup (#31) --- code/Executable/Executable.csproj | 1 + code/Executable/Program.cs | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/code/Executable/Executable.csproj b/code/Executable/Executable.csproj index 023e9807..5a03342d 100644 --- a/code/Executable/Executable.csproj +++ b/code/Executable/Executable.csproj @@ -3,6 +3,7 @@ cleanuperr net9.0 + 0.0.1 enable enable dotnet-Executable-6108b2ba-f035-47bc-addf-aaf5e20da4b8 diff --git a/code/Executable/Program.cs b/code/Executable/Program.cs index 1c1ebb29..c7b41576 100644 --- a/code/Executable/Program.cs +++ b/code/Executable/Program.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Executable.DependencyInjection; var builder = Host.CreateApplicationBuilder(args); @@ -7,4 +8,14 @@ builder.Logging.AddLogging(builder.Configuration); var host = builder.Build(); +var logger = host.Services.GetRequiredService>(); + +var version = Assembly.GetExecutingAssembly().GetName().Version; + +logger.LogInformation( + version is null + ? "cleanuperr version not detected" + : $"cleanuperr v{version.Major}.{version.Minor}.{version.Build}" +); + host.Run(); \ No newline at end of file