From 59ce3b5fc01a96e65af8a3edef7288b5f5123000 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Fri, 27 Oct 2017 12:08:18 +0900 Subject: [PATCH] Add footer to know what is the current running build --- BTCPayServer/Hosting/BTCPayServerServices.cs | 1 + .../Services/BTCPayServerEnvironment.cs | 47 +++++++++++++++++++ BTCPayServer/Views/Shared/_Layout.cshtml | 5 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 BTCPayServer/Services/BTCPayServerEnvironment.cs diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index 1c749224b..b929e1f00 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -113,6 +113,7 @@ namespace BTCPayServer.Hosting runtime.Configure(o.GetRequiredService()); return runtime; }); + services.AddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(o => o.GetRequiredService().InvoiceRepository); services.TryAddSingleton(o => o.GetRequiredService().Network); diff --git a/BTCPayServer/Services/BTCPayServerEnvironment.cs b/BTCPayServer/Services/BTCPayServerEnvironment.cs new file mode 100644 index 000000000..3d98d74ba --- /dev/null +++ b/BTCPayServer/Services/BTCPayServerEnvironment.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using System.Reflection; +using System.Text; + +namespace BTCPayServer.Services +{ + public class BTCPayServerEnvironment + { + public BTCPayServerEnvironment(IHostingEnvironment env) + { + Version = typeof(BTCPayServerEnvironment).GetTypeInfo().Assembly.GetCustomAttribute().Version; +#if DEBUG + Build = "Debug"; +#else + Build = "Release"; +#endif + Environment = env; + } + public IHostingEnvironment Environment + { + get; set; + } + public string Version + { + get; set; + } + public string Build + { + get; set; + } + public override string ToString() + { + StringBuilder txt = new StringBuilder(); + txt.Append($"@Copyright BTCPayServer v{Version}"); + if(!Environment.IsProduction() || Build.Equals("Release", StringComparison.OrdinalIgnoreCase)) + { + txt.Append($" Environment: {Environment.EnvironmentName} Build: {Build}"); + } + return txt.ToString(); + } + } +} diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index d8705ee56..3dd2f9d44 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -1,6 +1,7 @@ @inject SignInManager SignInManager @inject UserManager UserManager @inject RoleManager RoleManager +@inject BTCPayServer.Services.BTCPayServerEnvironment env @@ -75,7 +76,9 @@ @RenderBody() - +
+
@env.ToString()
+