Skip to content

Commit

Permalink
Merge pull request #224 from NLog/fix-assembly-version-renderer-net4.x
Browse files Browse the repository at this point in the history
Fix assembly-version
  • Loading branch information
304NotModified authored Nov 30, 2017
2 parents c04b4aa + 6855a5a commit 6265c40
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
{
Expand Down
45 changes: 24 additions & 21 deletions NLog.Web.AspNetCore/NLog.Web.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Extend NLog with targets and layout renderers for websites and webapplications on the ASP.NET Core platform.</Description>
<AssemblyTitle>NLog.Web.AspNetCore</AssemblyTitle>

<Authors>Julian Verdurmen</Authors>
<TargetFrameworks>netstandard1.3;netstandard1.5;net451;netstandard2.0</TargetFrameworks>
<DefineConstants>$(DefineConstants);ASP_NET_CORE</DefineConstants>
Expand All @@ -15,25 +15,25 @@
<PackageId>NLog.Web.AspNetCore</PackageId>
<PackageTags>logging;log;session;NLog;web;aspnet;aspnetcore;MVC</PackageTags>
<PackageReleaseNotes>
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 &lt;add assembly="NLog.Web.AspNetCore"/&gt; 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 &lt;add assembly="NLog.Web.AspNetCore"/&gt; unneeded for ASP.NET Core 2
- Fix IHttpContextAccessor warning
- Add IncludeScheme option to ${aspnet-request-url}
- Updated and limit dependencies

</PackageReleaseNotes>
</PackageReleaseNotes>
<PackageIconUrl>http://nlog-project.org/N.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/NLog/NLog.Web</PackageProjectUrl>
<PackageLicenseUrl>http://raw.github.com/NLog/NLog.Web/master/LICENSE</PackageLicenseUrl>
Expand All @@ -52,9 +52,9 @@ Beta 1
</PropertyGroup>

<ItemGroup>





<PackageReference Include="NLog.Extensions.Logging" Version="1.0.0-rtm-rc2" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>
Expand All @@ -68,18 +68,21 @@ Beta 1
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="1.1.1" />

</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="2.0.0" />


</ItemGroup>
<ItemGroup>

</ItemGroup>


Expand Down

0 comments on commit 6265c40

Please sign in to comment.