From 6855a5a168425ab75cdaedb2bcd9611ab32f0f85 Mon Sep 17 00:00:00 2001 From: Julian Verdurmen <304NotModified@users.noreply.github.com> Date: Thu, 30 Nov 2017 23:46:44 +0100 Subject: [PATCH] Fix assembly-version --- .../AssemblyVersionLayoutRenderer.cs | 36 +++++---------- .../NLog.Web.AspNetCore.csproj | 45 ++++++++++--------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/NLog.Web.AspNetCore/LayoutRenderers/AssemblyVersionLayoutRenderer.cs b/NLog.Web.AspNetCore/LayoutRenderers/AssemblyVersionLayoutRenderer.cs index 436ae9f9..f1ac8389 100644 --- a/NLog.Web.AspNetCore/LayoutRenderers/AssemblyVersionLayoutRenderer.cs +++ b/NLog.Web.AspNetCore/LayoutRenderers/AssemblyVersionLayoutRenderer.cs @@ -8,12 +8,10 @@ using NLog.LayoutRenderers; #if ASP_NET_CORE -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; #endif -#if ASP_NET_CORE && !NETSTANDARD2_0 +#if ASP_NET_CORE && NETSTANDARD1_3 using Microsoft.Extensions.PlatformAbstractions; #endif @@ -65,36 +63,26 @@ protected override void Append(StringBuilder builder, LogEventInfo logEvent) } -#if ASP_NET_CORE && !NETSTANDARD2_0 private static string GetAssemblyVersion() { - return PlatformServices.Default.Application.RuntimeFramework.Version.ToString(); - } -#elif NETSTANDARD2_0 - private static string GetAssemblyVersion() - { - return System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); - } +#if ASP_NET_CORE && NETSTANDARD1_3 + return PlatformServices.Default.Application.ApplicationVersion; #else - private static string GetAssemblyVersion() - { - var assembly = Assembly.GetEntryAssembly(); + +#if !ASP_NET_CORE if (assembly == null) { assembly = GetAspNetEntryAssembly(); } - if (assembly == null) - { - return null; - } - else - { - var version = assembly.GetName().Version.ToString(); - return version; - } +#endif + + var version = assembly?.GetName().Version.ToString(); + return version; +#endif + } - +#if !ASP_NET_CORE private static Assembly GetAspNetEntryAssembly() { diff --git a/NLog.Web.AspNetCore/NLog.Web.AspNetCore.csproj b/NLog.Web.AspNetCore/NLog.Web.AspNetCore.csproj index 679024a9..4514fe7d 100644 --- a/NLog.Web.AspNetCore/NLog.Web.AspNetCore.csproj +++ b/NLog.Web.AspNetCore/NLog.Web.AspNetCore.csproj @@ -3,7 +3,7 @@ Extend NLog with targets and layout renderers for websites and webapplications on the ASP.NET Core platform. NLog.Web.AspNetCore - + Julian Verdurmen netstandard1.3;netstandard1.5;net451;netstandard2.0 $(DefineConstants);ASP_NET_CORE @@ -15,25 +15,25 @@ NLog.Web.AspNetCore logging;log;session;NLog;web;aspnet;aspnetcore;MVC - Beta 4: updated dependencies - - Beta 3 + Beta 4: updated dependencies + + Beta 3 + + - Fixed ${callsite} in Asp.Net Core 2 when before using UseNLog() -- Fixed ${callsite} in Asp.Net Core 2 when before using UseNLog() + Beta 2 + - Better compatiblity with NLog.Web.AspNetCore 4.4 + - Fixed ${callsite} in Asp.Net Core 2 when using UseNLog() -Beta 2 -- Better compatiblity with NLog.Web.AspNetCore 4.4 -- Fixed ${callsite} in Asp.Net Core 2 when using UseNLog() - -Beta 1 -- ASP.NET Core 2 support (UseNLog) - use the new method for configuring NLog! See https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2 -- make <add assembly="NLog.Web.AspNetCore"/> unneeded for ASP.NET Core 2 -- Fix IHttpContextAccessor warning -- Add IncludeScheme option to ${aspnet-request-url} -- Updated and limit dependencies + Beta 1 + - ASP.NET Core 2 support (UseNLog) - use the new method for configuring NLog! See https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2 + - make <add assembly="NLog.Web.AspNetCore"/> unneeded for ASP.NET Core 2 + - Fix IHttpContextAccessor warning + - Add IncludeScheme option to ${aspnet-request-url} + - Updated and limit dependencies - + http://nlog-project.org/N.png https://github.com/NLog/NLog.Web http://raw.github.com/NLog/NLog.Web/master/LICENSE @@ -52,9 +52,9 @@ Beta 1 - - + + @@ -68,6 +68,9 @@ Beta 1 + + + @@ -75,11 +78,11 @@ Beta 1 - - + + - +