Skip to content

Commit 3f9593e

Browse files
committed
Remove out of support target frameworks in tests and sample
* Add .NET 6 target framework instead * Update tests and sample dependencies * Simplify conditional package references in all projects * Remove the custom `PRIVATE_BIN` define, use the built-in `NETFRAMEWORK` instead * Also use the Visual Studio 2022 image on AppVeyor because VS 2022 is required for the .NET 6 SDK * Add a reference to `Microsoft.TestPlatform.ObjectModel` so that `dotnet test` also works on Linux and macOS for the .NET Framework targets * Depend on Microsoft.Extensions.Configuration.Binder: there's no need to depend on Microsoft.Extensions.Options.ConfigurationExtensions, taking a dependency on Microsoft.Extensions.Configuration.Binder is enough for what Serilog.Settings.Configuration needs to do.
1 parent e02d19e commit 3f9593e

File tree

12 files changed

+117
-163
lines changed

12 files changed

+117
-163
lines changed

Build.ps1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ foreach ($test in dir test/*.Tests) {
4343
echo "build: Testing project in $test"
4444

4545
if ($PSVersionTable.Platform -eq "Unix") {
46-
& dotnet test -c Release -f netcoreapp2.1
4746
& dotnet test -c Release -f netcoreapp3.1
48-
& dotnet test -c Release -f net50
47+
& dotnet test -c Release -f net6.0
4948
} else {
5049
& dotnet test -c Release
5150
}
@@ -58,13 +57,10 @@ foreach ($test in dir test/*.Tests) {
5857
if ($PSVersionTable.Platform -eq "Unix") {
5958
Push-Location sample/Sample
6059

61-
& dotnet run -f netcoreapp2.1 -c Release --run-once
62-
if ($LASTEXITCODE -ne 0) { exit 4 }
63-
6460
& dotnet run -f netcoreapp3.1 -c Release --run-once
6561
if ($LASTEXITCODE -ne 0) { exit 4 }
6662

67-
& dotnet run -f net50 -c Release --run-once
63+
& dotnet run -f net6.0 -c Release --run-once
6864
if ($LASTEXITCODE -ne 0) { exit 4 }
6965

7066
Pop-Location

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
</PropertyGroup>
77

88
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
9-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="all" />
9+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
1010
</ItemGroup>
1111
</Project>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '{build}'
22
skip_tags: true
33
image:
4-
- Visual Studio 2019
4+
- Visual Studio 2022
55
- Ubuntu
66
configuration: Release
77
build_script:

sample/Sample/Sample.csproj

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net50;netcoreapp3.1;netcoreapp2.1;net46</TargetFrameworks>
4+
<TargetFrameworks>net6.0;netcoreapp3.1;net462</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

8-
<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
8+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
99
<PreserveCompilationContext>false</PreserveCompilationContext>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
1313
<ProjectReference Include="..\..\src\Serilog.Settings.Configuration\Serilog.Settings.Configuration.csproj" />
1414
</ItemGroup>
1515

16-
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
17-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
18-
<PackageReference Include="Serilog.Filters.Expressions" Version="2.1.0" />
19-
</ItemGroup>
20-
21-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
22-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
23-
<PackageReference Include="Serilog.Filters.Expressions" Version="2.1.0" />
24-
</ItemGroup>
25-
26-
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
27-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.10" />
28-
<PackageReference Include="Serilog.Expressions" Version="1.0.0" />
29-
</ItemGroup>
30-
31-
<ItemGroup Condition="'$(TargetFramework)' == 'net50'">
32-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
33-
<PackageReference Include="Serilog.Expressions" Version="1.0.0" />
34-
</ItemGroup>
35-
3616
<ItemGroup>
37-
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
38-
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
39-
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
40-
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
17+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
18+
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
19+
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
20+
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
21+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
22+
<PackageReference Include="Serilog.Expressions" Version="3.3.0" />
4123
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
4224
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
4325
</ItemGroup>

src/Serilog.Settings.Configuration/Serilog.Settings.Configuration.csproj

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,18 @@
2424
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2525
</PropertyGroup>
2626

27-
<PropertyGroup Condition="('$(TargetFramework)' == 'net451') Or ('$(TargetFramework)' == 'net461')">
28-
<DefineConstants>$(DefineConstants);PRIVATE_BIN</DefineConstants>
29-
</PropertyGroup>
30-
3127
<ItemGroup>
32-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
28+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
3329
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.0.0" />
3430
<PackageReference Include="Serilog" Version="2.10.0" />
35-
<None Include="..\..\assets\icon.png" Pack="true" PackagePath=""/>
31+
<None Include="..\..\assets\icon.png" Pack="true" PackagePath="" />
3632
</ItemGroup>
37-
38-
<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
39-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.2" />
33+
34+
<ItemGroup Condition="$(TargetFramework) == 'net451'">
35+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="1.1.2" />
4036
</ItemGroup>
4137

42-
<ItemGroup Condition="('$(TargetFramework)' == 'netstandard2.0') Or ('$(TargetFramework)' == 'net461')">
43-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
38+
<ItemGroup Condition="$(TargetFramework) != 'net451'">
39+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
4440
</ItemGroup>
4541
</Project>

src/Serilog.Settings.Configuration/Settings/Configuration/Assemblies/DllScanningAssemblyFinder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -16,7 +16,7 @@ public override IReadOnlyList<AssemblyName> FindAssembliesContainingName(string
1616
{
1717
probeDirs.Add(AppDomain.CurrentDomain.BaseDirectory);
1818

19-
#if PRIVATE_BIN
19+
#if NETFRAMEWORK
2020
var privateBinPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
2121
if (!string.IsNullOrEmpty(privateBinPath))
2222
{

test/Serilog.Settings.Configuration.Tests/ConfigurationReaderTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public void WriteToSupportSimplifiedSyntax()
3131
Assert.True(result.Contains("LiterateConsole"));
3232
Assert.True(result.Contains("DiagnosticTrace"));
3333

34-
Assert.Equal(1, result["LiterateConsole"].Count());
35-
Assert.Equal(1, result["DiagnosticTrace"].Count());
34+
Assert.Single(result["LiterateConsole"]);
35+
Assert.Single(result["DiagnosticTrace"]);
3636
}
3737

3838
[Fact]
@@ -49,7 +49,7 @@ public void WriteToSupportExpandedSyntaxWithoutArgs()
4949
Assert.Equal(1, result.Count);
5050
Assert.True(result.Contains("LiterateConsole"));
5151

52-
Assert.Equal(1, result["LiterateConsole"].Count());
52+
Assert.Single(result["LiterateConsole"]);
5353
}
5454

5555
[Fact]
@@ -67,14 +67,14 @@ public void WriteToSupportExpandedSyntaxWithArgs()
6767

6868
var result = _configurationReader.GetMethodCalls(JsonStringConfigSource.LoadSection(json, "WriteTo"));
6969

70-
Assert.Equal(1, result.Count);
70+
Assert.Single(result);
7171
Assert.True(result.Contains("LiterateConsole"));
7272

73-
Assert.Equal(1, result["LiterateConsole"].Count());
73+
Assert.Single(result["LiterateConsole"]);
7474

7575
var args = result["LiterateConsole"].Single().ToArray();
7676

77-
Assert.Equal(1, args.Length);
77+
Assert.Single(args);
7878
Assert.Equal("outputTemplate", args[0].Key);
7979
Assert.Equal("{Message}", args[0].Value.ConvertTo(typeof(string), new ResolutionContext()));
8080
}
@@ -114,8 +114,8 @@ public void WriteToSupportMultipleSinksOfTheSameKind()
114114
Assert.True(result.Contains("DiagnosticTrace"));
115115
Assert.True(result.Contains("File"));
116116

117-
Assert.Equal(1, result["LiterateConsole"].Count());
118-
Assert.Equal(1, result["DiagnosticTrace"].Count());
117+
Assert.Single(result["LiterateConsole"]);
118+
Assert.Single(result["DiagnosticTrace"]);
119119
Assert.Equal(2, result["File"].Count());
120120
}
121121

@@ -133,9 +133,9 @@ public void Enrich_SupportSimplifiedSyntax()
133133
Assert.True(result.Contains("WithMachineName"));
134134
Assert.True(result.Contains("WithThreadId"));
135135

136-
Assert.Equal(1, result["FromLogContext"].Count());
137-
Assert.Equal(1, result["WithMachineName"].Count());
138-
Assert.Equal(1, result["WithThreadId"].Count());
136+
Assert.Single(result["FromLogContext"]);
137+
Assert.Single(result["WithMachineName"]);
138+
Assert.Single(result["WithThreadId"]);
139139
}
140140

141141
[Fact]

0 commit comments

Comments
 (0)