Skip to content

Commit 86fed08

Browse files
authored
Merge pull request #444 from nblumhardt/dotnet-9
Update to .NET 9 SDK and `Microsoft.Extensions.Configuration` 9.0.0
2 parents d60efa0 + 407e54d commit 86fed08

15 files changed

+181
-125
lines changed

Diff for: .github/workflows/ci.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# If this file is renamed, the incrementing run attempt number will be reset.
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [ "dev", "main" ]
8+
pull_request:
9+
branches: [ "dev", "main" ]
10+
11+
env:
12+
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
13+
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
14+
15+
jobs:
16+
build:
17+
18+
# The build must run on Windows so that .NET Framework targets can be built and tested.
19+
runs-on: windows-latest
20+
21+
permissions:
22+
contents: write
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Setup
27+
uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: 9.0.x
30+
- name: Compute build number
31+
shell: bash
32+
run: |
33+
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
34+
- name: Build and Publish
35+
env:
36+
DOTNET_CLI_TELEMETRY_OPTOUT: true
37+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
shell: pwsh
40+
run: |
41+
./Build.ps1

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,5 @@ FakesAssemblies/
201201
project.lock.json
202202

203203
artifacts/
204+
205+
.DS_Store

Diff for: Build.ps1

+66-25
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,79 @@
1+
Write-Output "build: Tool versions follow"
2+
3+
dotnet --version
4+
dotnet --list-sdks
5+
16
Write-Output "build: Build started"
27

38
Push-Location $PSScriptRoot
9+
try {
10+
if(Test-Path .\artifacts) {
11+
Write-Output "build: Cleaning ./artifacts"
12+
Remove-Item ./artifacts -Force -Recurse
13+
}
414

5-
if(Test-Path .\artifacts) {
6-
Write-Output "build: Cleaning .\artifacts"
7-
Remove-Item .\artifacts -Force -Recurse
8-
}
15+
& dotnet restore --no-cache
916

10-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
11-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
12-
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
13-
$commitHash = $(git rev-parse --short HEAD)
14-
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
17+
$dbp = [Xml] (Get-Content .\Directory.Version.props)
18+
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
1519

16-
Write-Output "build: Package version suffix is $suffix"
17-
Write-Output "build: Build version suffix is $buildSuffix"
20+
Write-Output "build: Package version prefix is $versionPrefix"
1821

19-
& dotnet build --configuration Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
22+
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
23+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
24+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
25+
$commitHash = $(git rev-parse --short HEAD)
26+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
2027

21-
if($LASTEXITCODE -ne 0) { throw 'build failed' }
28+
Write-Output "build: Package version suffix is $suffix"
29+
Write-Output "build: Build version suffix is $buildSuffix"
2230

23-
if($suffix) {
24-
& dotnet pack src\Serilog.Settings.Configuration --configuration Release --no-build --no-restore -o artifacts --version-suffix=$suffix
25-
} else {
26-
& dotnet pack src\Serilog.Settings.Configuration --configuration Release --no-build --no-restore -o artifacts
27-
}
31+
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
32+
if($LASTEXITCODE -ne 0) { throw "Build failed" }
33+
34+
foreach ($src in Get-ChildItem src/*) {
35+
Push-Location $src
36+
37+
Write-Output "build: Packaging project in $src"
38+
39+
if ($suffix) {
40+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
41+
} else {
42+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts
43+
}
44+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
2845

29-
if($LASTEXITCODE -ne 0) { throw 'pack failed' }
46+
Pop-Location
47+
}
3048

31-
Write-Output "build: Testing"
49+
foreach ($test in Get-ChildItem test/*.Tests) {
50+
Push-Location $test
3251

33-
# Dotnet test doesn't run separate TargetFrameworks in parallel: https://github.com/dotnet/sdk/issues/19147
34-
# Workaround: use `dotnet test` on dlls directly in order to pass the `--parallel` option to vstest.
35-
# The _reported_ runtime is wrong but the _actual_ used runtime is correct, see https://github.com/microsoft/vstest/issues/2037#issuecomment-720549173
36-
& dotnet test test\Serilog.Settings.Configuration.Tests\bin\Release\*\Serilog.Settings.Configuration.Tests.dll --parallel
52+
Write-Output "build: Testing project in $test"
3753

38-
if($LASTEXITCODE -ne 0) { throw 'unit tests failed' }
54+
& dotnet test -c Release --no-build --no-restore
55+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
56+
57+
Pop-Location
58+
}
59+
60+
if ($env:NUGET_API_KEY) {
61+
# GitHub Actions will only supply this to branch builds and not PRs. We publish
62+
# builds from any branch this action targets (i.e. main and dev).
63+
64+
Write-Output "build: Publishing NuGet packages"
65+
66+
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
67+
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
68+
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
69+
}
70+
71+
if (!($suffix)) {
72+
Write-Output "build: Creating release for version $versionPrefix"
73+
74+
iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
75+
}
76+
}
77+
} finally {
78+
Pop-Location
79+
}

Diff for: Directory.Build.props

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
<Project>
2+
<!-- Properties in this file are expected to be identical for all Serilog organization projects. If
3+
a property value is project-specific, please record it in the CSPROJ file instead. -->
4+
<Import Project="$(MSBuildThisFileDirectory)Directory.Version.props" />
25
<PropertyGroup>
36
<LangVersion>latest</LangVersion>
47
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
5-
<SignAssembly>true</SignAssembly>
8+
<!-- The condition is required to support BenchmarkDotNet -->
9+
<SignAssembly Condition="Exists('$(MSBuildThisFileDirectory)assets/Serilog.snk')">true</SignAssembly>
610
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)assets/Serilog.snk</AssemblyOriginatorKeyFile>
7-
<ImplicitUsings>enable</ImplicitUsings>
811
<CheckEolTargetFramework>false</CheckEolTargetFramework>
912
<Nullable>enable</Nullable>
13+
<ImplicitUsings>enable</ImplicitUsings>
14+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
15+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
16+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
17+
<IncludeSymbols>true</IncludeSymbols>
18+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1019
</PropertyGroup>
20+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
21+
<Reference Include="System" />
22+
<Reference Include="System.Core" />
23+
<Reference Include="Microsoft.CSharp" />
24+
</ItemGroup>
1125
</Project>

Diff for: Directory.Version.props

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- This must match the major and minor components of the referenced Microsoft.Extensions.Configuration package. -->
4+
<VersionPrefix>9.0.0</VersionPrefix>
5+
</PropertyGroup>
6+
</Project>

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Serilog.Settings.Configuration [![Build status](https://ci.appveyor.com/api/projects/status/r2bgfimd9ocr61px/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-settings-configuration/branch/master) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Settings.Configuration.svg?style=flat)](https://www.nuget.org/packages/Serilog.Settings.Configuration/)
1+
# Serilog.Settings.Configuration [![Build status](https://github.com/serilog/serilog-settings-configuration/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/serilog/serilog-settings-configuration/actions)&nbsp;[![NuGet Version](http://img.shields.io/nuget/v/Serilog.Settings.Configuration.svg?style=flat)](https://www.nuget.org/packages/Serilog.Settings.Configuration/)
22

33
A Serilog settings provider that reads from [Microsoft.Extensions.Configuration](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1) sources, including .NET Core's `appsettings.json` file.
44

@@ -349,7 +349,7 @@ public record MyDto(int Id, int Name);
349349
350350
public class FirstDestructuringPolicy : IDestructuringPolicy
351351
{
352-
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory,
352+
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory,
353353
[NotNullWhen(true)] out LogEventPropertyValue? result)
354354
{
355355
if (value is not MyDto dto)

Diff for: appveyor.yml

-52
This file was deleted.

Diff for: global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.100",
44
"allowPrerelease": false,
55
"rollForward": "latestFeature"
66
}

Diff for: sample/Sample/Sample.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>net462;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net462;net8.0;net9.0</TargetFrameworks>
55
<OutputType>Exe</OutputType>
6+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
67
</PropertyGroup>
78

89
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
@@ -14,15 +15,15 @@
1415
</ItemGroup>
1516

1617
<ItemGroup>
17-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
18-
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
19-
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
20-
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
21-
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
18+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
19+
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
20+
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
21+
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
22+
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
2223
<PackageReference Include="Serilog.Expressions" Version="4.0.0" />
23-
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
24+
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
2425
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
25-
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="all" />
26+
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="all" />
2627
</ItemGroup>
2728

2829
<ItemGroup>

Diff for: serilog-settings-configuration.sln

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{62D0B9
99
ProjectSection(SolutionItems) = preProject
1010
.editorconfig = .editorconfig
1111
.gitignore = .gitignore
12-
appveyor.yml = appveyor.yml
1312
Build.ps1 = Build.ps1
1413
CHANGES.md = CHANGES.md
1514
Directory.Build.props = Directory.Build.props
@@ -18,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{62D0B9
1817
README.md = README.md
1918
serilog-settings-configuration.sln.DotSettings = serilog-settings-configuration.sln.DotSettings
2019
global.json = global.json
20+
Directory.Version.props = Directory.Version.props
2121
EndProjectSection
2222
EndProject
2323
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}"
@@ -34,6 +34,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestDummies", "test\TestDum
3434
EndProject
3535
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "test\TestApp\TestApp.csproj", "{1B6E08F3-16C9-4912-BEEE-57DB78C92A12}"
3636
EndProject
37+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{21A409AD-2C11-41A8-88C8-360062EA8E48}"
38+
EndProject
39+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{391B84C5-A7BA-4BE1-95A0-E459FA61D971}"
40+
ProjectSection(SolutionItems) = preProject
41+
.github\workflows\ci.yml = .github\workflows\ci.yml
42+
EndProjectSection
43+
EndProject
3744
Global
3845
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3946
Debug|Any CPU = Debug|Any CPU
@@ -68,6 +75,7 @@ Global
6875
{A00E5E32-54F9-401A-BBA1-2F6FCB6366CD} = {D24872B9-57F3-42A7-BC8D-F9DA222FCE1B}
6976
{B7CF5068-DD19-4868-A268-5280BDE90361} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}
7077
{1B6E08F3-16C9-4912-BEEE-57DB78C92A12} = {D551DCB0-7771-4D01-BEBD-F7B57D1CF0E3}
78+
{391B84C5-A7BA-4BE1-95A0-E459FA61D971} = {21A409AD-2C11-41A8-88C8-360062EA8E48}
7179
EndGlobalSection
7280
GlobalSection(ExtensibilityGlobals) = postSolution
7381
SolutionGuid = {485F8843-42D7-4267-B5FB-20FE9181DEE9}

Diff for: src/Serilog.Settings.Configuration/Serilog.Settings.Configuration.csproj

+6-14
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,34 @@
22

33
<PropertyGroup>
44
<Description>Microsoft.Extensions.Configuration (appsettings.json) support for Serilog.</Description>
5-
<!-- This must match the major and minor components of the referenced Microsoft.Extensions.Logging package. -->
6-
<VersionPrefix>8.0.5</VersionPrefix>
75
<Authors>Serilog Contributors</Authors>
8-
<!-- These must match the Dependencies tab in https://www.nuget.org/packages/microsoft.settings.configuration at
6+
<!-- These must match the Dependencies tab in https://www.nuget.org/packages/microsoft.extensions.configuration at
97
the target version. -->
10-
<TargetFrameworks>net462;netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
8+
<TargetFrameworks>net462;netstandard2.0;net8.0;net9.0</TargetFrameworks>
119
<GenerateDocumentationFile>true</GenerateDocumentationFile>
12-
<AssemblyName>Serilog.Settings.Configuration</AssemblyName>
13-
<PackageTags>serilog;json</PackageTags>
10+
<PackageTags>serilog;json;appsettings</PackageTags>
1411
<PackageIcon>icon.png</PackageIcon>
1512
<PackageReadmeFile>README.md</PackageReadmeFile>
1613
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1714
<PackageProjectUrl>https://github.com/serilog/serilog-settings-configuration</PackageProjectUrl>
1815
<PackageReleaseNotes>$(PackageProjectUrl)/releases</PackageReleaseNotes>
1916
<RootNamespace>Serilog</RootNamespace>
20-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
21-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
22-
<IncludeSymbols>true</IncludeSymbols>
23-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2417
</PropertyGroup>
2518

2619
<ItemGroup>
2720
<Using Remove="System.Net.Http" />
2821
</ItemGroup>
2922

3023
<ItemGroup>
31-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
3224
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="All" />
33-
<PackageReference Include="Serilog" Version="3.1.1" />
25+
<PackageReference Include="Serilog" Version="4.2.0-*" />
3426
<None Include="..\..\assets\icon.png" Pack="true" PackagePath="" Visible="false" />
3527
<None Include="..\..\README.md" Pack="true" PackagePath="" />
3628
</ItemGroup>
3729

3830
<ItemGroup>
3931
<!-- The versions of all references in this group must match the major and minor components of the package version prefix. -->
40-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
41-
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.2" />
32+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
33+
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="9.0.0" />
4234
</ItemGroup>
4335
</Project>

0 commit comments

Comments
 (0)