Skip to content

Commit 326979b

Browse files
authored
Introduced NET6 since NET5 is no longer supported (#629)
1 parent 01dfbb5 commit 326979b

File tree

10 files changed

+36
-32
lines changed

10 files changed

+36
-32
lines changed

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ test_script:
2323
- nuget.exe install OpenCover -ExcludeVersion -DependencyVersion Ignore
2424
- OpenCover\tools\OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net461 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
2525
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
26-
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net5.0 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
26+
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net6.0 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
2727
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net461 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
2828
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
29-
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net5.0 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
29+
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net6.0 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
3030
- pip install codecov
3131
- codecov -f "coverage.xml"
3232
- set JAVA_HOME=C:\Program Files\Java\jdk16

build.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ if (-Not $LastExitCode -eq 0) {
2626
exit $LastExitCode
2727
}
2828

29-
msbuild /t:Pack .\src\NLog.Extensions.Logging\ /p:targetFrameworks='"net461;netstandard1.3;netstandard1.5;netstandard2.0;netcoreapp3.1;net5.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
29+
msbuild /t:Pack .\src\NLog.Extensions.Logging\ /p:targetFrameworks='"net461;netstandard1.3;netstandard1.5;netstandard2.0;netstandard2.1;net6.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
3030
if (-Not $LastExitCode -eq 0) {
3131
exit $LastExitCode
3232
}
3333

34-
msbuild /t:Pack .\src\NLog.Extensions.Hosting\ /p:targetFrameworks='"netstandard2.0;netcoreapp3.1;net5.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
34+
msbuild /t:Pack .\src\NLog.Extensions.Hosting\ /p:targetFrameworks='"netstandard2.0;netstandard2.1;net6.0"' /p:VersionPrefix=$versionPrefix /p:VersionSuffix=$versionSuffix /p:FileVersion=$versionFile /p:ProductVersion=$versionProduct /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:PackageOutputPath=..\..\artifacts /verbosity:minimal /p:ContinuousIntegrationBuild=true
3535
if (-Not $LastExitCode -eq 0) {
3636
exit $LastExitCode
3737
}

src/NLog.Extensions.Hosting/NLog.Extensions.Hosting.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
55
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -40,12 +40,12 @@ Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHAN
4040
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" />
4141
</ItemGroup>
4242

43-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
43+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
4444
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" />
4545
</ItemGroup>
4646

47-
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
48-
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
47+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
48+
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
4949
</ItemGroup>
5050

5151
<ItemGroup>

src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET5_0
1+
#if NET6_0
22

33
using System.Diagnostics;
44

src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<string, ob
5858
{
5959
scopePropertyList = ExcludeOriginalFormatProperty(scopePropertyList);
6060
}
61-
else if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
61+
else
6262
{
6363
scopePropertyList = IncludeActivityIdsProperties(scopePropertyList);
6464
}
@@ -68,19 +68,22 @@ private IDisposable CaptureScopeProperties(IReadOnlyList<KeyValuePair<string, ob
6868
return ScopeContext.PushNestedStateProperties(scopeObject, scopePropertyList);
6969
}
7070

71-
#if !NET5_0
71+
#if !NET6_0
7272
private static IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
7373
{
74-
return scopePropertyList;
74+
return scopePropertyList; // Not supported
7575
}
7676
#else
77-
private static IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
77+
private IReadOnlyList<KeyValuePair<string, object>> IncludeActivityIdsProperties(IReadOnlyList<KeyValuePair<string, object>> scopePropertyList)
7878
{
79-
if (scopePropertyList.Count > 1 && "RequestPath".Equals(scopePropertyList[1].Key))
79+
if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key))
8080
{
81-
var activty = System.Diagnostics.Activity.Current;
82-
if (activty != null)
83-
return new ScopePropertiesWithActivityIds(scopePropertyList, activty);
81+
if (scopePropertyList.Count > 1 && "RequestPath".Equals(scopePropertyList[1].Key))
82+
{
83+
var activty = System.Diagnostics.Activity.Current;
84+
if (activty != null)
85+
return new ScopePropertiesWithActivityIds(scopePropertyList, activty);
86+
}
8487
}
8588

8689
return scopePropertyList;

src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class NLogProviderOptions
5555
/// </summary>
5656
public bool AutoShutdown { get; set; }
5757

58-
#if NET5_0
58+
#if NET6_0
5959
/// <summary>
6060
/// Automatically include <see cref="System.Diagnostics.Activity.SpanId"/>, <see cref="System.Diagnostics.Activity.TraceId"/> and <see cref="System.Diagnostics.Activity.ParentId"/>
6161
/// </summary>
@@ -73,6 +73,7 @@ public class NLogProviderOptions
7373
///
7474
/// Consider using <a href="https://www.nuget.org/packages/NLog.DiagnosticSource/">${activity}</a> as alternative
7575
/// </remarks>
76+
[Obsolete("Only supported with NET6 (or newer)")]
7677
#endif
7778
public bool IncludeActivityIdsWithBeginScope { get; set; }
7879

src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net461;netstandard1.3;netstandard1.5;netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
3+
<TargetFrameworks>net461;netstandard1.3;netstandard1.5;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
44
<DebugType Condition=" '$(Configuration)' == 'Debug' ">Full</DebugType>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -57,12 +57,12 @@ List of major changes in NLog 5.0: https://nlog-project.org/2021/08/25/nlog-5-0-
5757
<Title>NLog.Extensions.Logging for .NET Standard 2.0</Title>
5858
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
5959
</PropertyGroup>
60-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
61-
<Title>NLog.Extensions.Logging for .NET Core 3.1</Title>
60+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
61+
<Title>NLog.Extensions.Logging for .NET Standard 2.1</Title>
6262
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
6363
</PropertyGroup>
64-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
65-
<Title>NLog.Extensions.Logging for .NET 5.0</Title>
64+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
65+
<Title>NLog.Extensions.Logging for .NET 6</Title>
6666
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
6767
</PropertyGroup>
6868
<PropertyGroup>
@@ -91,13 +91,13 @@ List of major changes in NLog 5.0: https://nlog-project.org/2021/08/25/nlog-5-0-
9191
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.0" />
9292
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.0" />
9393
</ItemGroup>
94-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
94+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
9595
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
9696
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.0" />
9797
</ItemGroup>
98-
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
99-
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
100-
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
98+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
99+
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
100+
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
101101
</ItemGroup>
102102

103103
<ItemGroup>

test/NLog.Extensions.Hosting.Tests/NLog.Extensions.Hosting.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net461;netcoreapp3.1;net5.0</TargetFrameworks>
3+
<TargetFrameworks>net461;netcoreapp3.1;net6.0</TargetFrameworks>
44
<OutputType>Library</OutputType>
55
<IsPackable>false</IsPackable>
66
<DebugType>full</DebugType>
@@ -22,7 +22,7 @@
2222
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
2323
</ItemGroup>
2424

25-
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
25+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
2626
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
2727
</ItemGroup>
2828

test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void AddNLog_LoggerFactory_LogInfoWithEventId_ShouldLogToNLogWithEventId(
5757
AssertSingleMessage(memoryTarget, $"{expectedEventInLog} - test message with 1 arg");
5858
}
5959

60-
#if NET5_0
60+
#if NET6_0
6161
[Fact]
6262
public void AddNLog_LoggerFactory_IncludeActivityIdsWithBeginScope()
6363
{

test/NLog.Extensions.Logging.Tests/NLog.Extensions.Logging.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net461;net5.0</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp3.1;net461;net6.0</TargetFrameworks>
55
<OutputType>Library</OutputType>
66
<IsPackable>false</IsPackable>
77
<DebugType>Full</DebugType>
@@ -30,7 +30,7 @@
3030
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
3131
</ItemGroup>
3232

33-
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
33+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
3434
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
3535
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
3636
</ItemGroup>

0 commit comments

Comments
 (0)