diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..acd3bc6
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,41 @@
+# If this file is renamed, the incrementing run attempt number will be reset.
+
+name: CI
+
+on:
+ push:
+ branches: [ "dev", "main" ]
+ pull_request:
+ branches: [ "dev", "main" ]
+
+env:
+ CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
+ CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
+
+jobs:
+ build:
+
+ # The build must run on Windows so that .NET Framework targets can be built and tested.
+ runs-on: windows-latest
+
+ permissions:
+ contents: write
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Setup
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: 9.0.x
+ - name: Compute build number
+ shell: bash
+ run: |
+ echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
+ - name: Build and Publish
+ env:
+ DOTNET_CLI_TELEMETRY_OPTOUT: true
+ NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ shell: pwsh
+ run: |
+ ./Build.ps1
diff --git a/.gitignore b/.gitignore
index a85b957..3ce8c4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -289,3 +289,5 @@ __pycache__/
samples/Sample/logs/
+.DS_Store
+
diff --git a/Build.ps1 b/Build.ps1
index a674b52..e798284 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -1,56 +1,79 @@
-echo "build: Build started"
+Write-Output "build: Tool versions follow"
+
+dotnet --version
+dotnet --list-sdks
+
+Write-Output "build: Build started"
Push-Location $PSScriptRoot
+try {
+ if(Test-Path .\artifacts) {
+ Write-Output "build: Cleaning ./artifacts"
+ Remove-Item ./artifacts -Force -Recurse
+ }
-if(Test-Path .\artifacts) {
- echo "build: Cleaning .\artifacts"
- Remove-Item .\artifacts -Force -Recurse
-}
+ & dotnet restore --no-cache
-& dotnet restore --no-cache
+ $dbp = [Xml] (Get-Content .\Directory.Version.props)
+ $versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
-$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
-$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
-$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
+ Write-Output "build: Package version prefix is $versionPrefix"
-echo "build: Version suffix is $suffix"
+ $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
+ $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
+ $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
+ $commitHash = $(git rev-parse --short HEAD)
+ $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
-foreach ($src in ls src/*) {
- Push-Location $src
+ Write-Output "build: Package version suffix is $suffix"
+ Write-Output "build: Build version suffix is $buildSuffix"
- echo "build: Packaging project in $src"
+ & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
+ if($LASTEXITCODE -ne 0) { throw "Build failed" }
- if($suffix) {
- & dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix
- } else {
- & dotnet pack -c Release --include-source -o ..\..\artifacts
- }
+ foreach ($src in Get-ChildItem src/*) {
+ Push-Location $src
- if($LASTEXITCODE -ne 0) { exit 1 }
+ Write-Output "build: Packaging project in $src"
- Pop-Location
-}
+ if ($suffix) {
+ & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
+ } else {
+ & dotnet pack -c Release --no-build --no-restore -o ../../artifacts
+ }
+ if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
-foreach ($test in ls test/*.PerformanceTests) {
- Push-Location $test
+ Pop-Location
+ }
- echo "build: Building performance test project in $test"
+ foreach ($test in Get-ChildItem test/*.Tests) {
+ Push-Location $test
- & dotnet build -c Release
- if($LASTEXITCODE -ne 0) { exit 2 }
+ Write-Output "build: Testing project in $test"
- Pop-Location
-}
+ & dotnet test -c Release --no-build --no-restore
+ if($LASTEXITCODE -ne 0) { throw "Testing failed" }
+
+ Pop-Location
+ }
-foreach ($test in ls test/*.Tests) {
- Push-Location $test
+ if ($env:NUGET_API_KEY) {
+ # GitHub Actions will only supply this to branch builds and not PRs. We publish
+ # builds from any branch this action targets (i.e. main and dev).
- echo "build: Testing project in $test"
+ Write-Output "build: Publishing NuGet packages"
- & dotnet test -c Release
- if($LASTEXITCODE -ne 0) { exit 3 }
+ foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
+ & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
+ if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
+ }
+ if (!($suffix)) {
+ Write-Output "build: Creating release for version $versionPrefix"
+
+ iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
+ }
+ }
+} finally {
Pop-Location
}
-
-Pop-Location
diff --git a/Directory.Build.props b/Directory.Build.props
index 3dcd183..c114992 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,12 +1,25 @@
+
+
latest
True
- true
- ../../assets/Serilog.snk
- true
+
+ true
+ $(MSBuildThisFileDirectory)assets/Serilog.snk
false
enable
enable
+ true
+ true
+ true
+ true
+ snupkg
+
+
+
+
+
diff --git a/Directory.Version.props b/Directory.Version.props
new file mode 100644
index 0000000..f350992
--- /dev/null
+++ b/Directory.Version.props
@@ -0,0 +1,6 @@
+
+
+
+ 9.0.0
+
+
diff --git a/README.md b/README.md
index 4b5ae29..9d09bf1 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Serilog.AspNetCore [![Build status](https://ci.appveyor.com/api/projects/status/4rscdto23ik6vm2r/branch/dev?svg=true)](https://ci.appveyor.com/project/serilog/serilog-aspnetcore/branch/dev) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.AspNetCore.svg?style=flat)](https://www.nuget.org/packages/Serilog.AspNetCore/) [![NuGet Prerelease Version](http://img.shields.io/nuget/vpre/Serilog.AspNetCore.svg?style=flat)](https://www.nuget.org/packages/Serilog.AspNetCore/)
+# Serilog.AspNetCore [![Build status](https://github.com/serilog/serilog-aspnetcore/actions/workflows/ci.yml/badge.svg?branch=dev)](https://github.com/serilog/serilog-aspnetcore/actions) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.AspNetCore.svg?style=flat)](https://www.nuget.org/packages/Serilog.AspNetCore/)
Serilog logging for ASP.NET Core. This package routes ASP.NET Core log messages through Serilog, so you can get information about ASP.NET's internal operations written to the same Serilog sinks as your application events.
diff --git a/Setup.ps1 b/Setup.ps1
deleted file mode 100644
index 880a07a..0000000
--- a/Setup.ps1
+++ /dev/null
@@ -1,11 +0,0 @@
-$ErrorActionPreference = "Stop"
-
-$RequiredDotnetVersion = $(cat ./global.json | convertfrom-json).sdk.version
-
-mkdir "./build"
-
-Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./build/installcli.ps1"
-& ./build/installcli.ps1 -InstallDir "$pwd/.dotnetcli" -NoPath -Version $RequiredDotnetVersion
-if ($LASTEXITCODE) { exit 1 }
-
-$env:Path = "$pwd/.dotnetcli;$env:Path"
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 5eadb66..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-version: '{build}'
-skip_tags: true
-image: Visual Studio 2022
-install:
-- ps: ./Setup.ps1
-build_script:
-- ps: ./Build.ps1
-test: off
-artifacts:
-- path: artifacts/Serilog.*.nupkg
-deploy:
-- provider: NuGet
- skip_symbols: true
- api_key:
- secure: cyyTkHHOJHO3tPWDeocu+EjnHERcPncSaEi/l2gjYPDsNP3I4zh/KPtbqt7kWVc0
- on:
- branch: /^(main|dev)$/
-- provider: GitHub
- auth_token:
- secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
- artifact: /Serilog.*\.nupkg/
- tag: v$(appveyor_build_version)
- on:
- branch: main
diff --git a/global.json b/global.json
index d079f83..db8627a 100644
--- a/global.json
+++ b/global.json
@@ -1,7 +1,7 @@
{
"sdk": {
+ "version": "9.0.100",
"allowPrerelease": false,
- "version": "8.0.100",
"rollForward": "latestFeature"
}
}
diff --git a/samples/Sample/Sample.csproj b/samples/Sample/Sample.csproj
index b5a6d67..446c9b8 100644
--- a/samples/Sample/Sample.csproj
+++ b/samples/Sample/Sample.csproj
@@ -1,7 +1,8 @@
- net8.0
+ net9.0
+ false
@@ -9,7 +10,7 @@
-
+
diff --git a/serilog-aspnetcore.sln b/serilog-aspnetcore.sln
index a9b5e42..73c077d 100644
--- a/serilog-aspnetcore.sln
+++ b/serilog-aspnetcore.sln
@@ -11,12 +11,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F240
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{9C21B9DF-AEDD-4AA6-BEA4-912DEF3E5B8E}"
ProjectSection(SolutionItems) = preProject
- appveyor.yml = appveyor.yml
- Build.ps1 = Build.ps1
- global.json = global.json
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
- Setup.ps1 = Setup.ps1
+ Build.ps1 = Build.ps1
+ global.json = global.json
+ Directory.Version.props = Directory.Version.props
Directory.Build.props = Directory.Build.props
EndProjectSection
EndProject
@@ -26,6 +25,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.AspNetCore.Tests",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "samples\Sample\Sample.csproj", "{4FA0FE41-973E-4555-AB4A-0F400DBA9DD3}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{B867CAF4-D737-4230-AD2F-8093223A949A}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{5944D1E2-BC3C-4A95-B4E2-9DDE5B0684AC}"
+ ProjectSection(SolutionItems) = preProject
+ .github\workflows\ci.yml = .github\workflows\ci.yml
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -52,6 +58,7 @@ Global
{0549D23F-986B-4FB2-BACE-16FD7A7BC9EF} = {A1893BD1-333D-4DFE-A0F0-DDBB2FE526E0}
{AD51759B-CD58-473F-9620-0B0E56A123A1} = {E30F638E-BBBE-4AD1-93CE-48CC69CFEFE1}
{4FA0FE41-973E-4555-AB4A-0F400DBA9DD3} = {F2407211-6043-439C-8E06-3641634332E7}
+ {5944D1E2-BC3C-4A95-B4E2-9DDE5B0684AC} = {B867CAF4-D737-4230-AD2F-8093223A949A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {811E61C5-3871-4633-AFAE-B35B619C8A10}
diff --git a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs
index e4f50a8..a8ec777 100644
--- a/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs
+++ b/src/Serilog.AspNetCore/AspNetCore/RequestLoggingMiddleware.cs
@@ -88,7 +88,7 @@ bool LogCompletion(HttpContext httpContext, DiagnosticContextCollector collector
collectedProperties = NoProperties;
// Last-in (correctly) wins...
- var properties = collectedProperties.Concat(_getMessageTemplateProperties(httpContext, GetPath(httpContext, _includeQueryInRequestPath), elapsedMs, statusCode));
+ var properties = (collectedProperties ?? []).Concat(_getMessageTemplateProperties(httpContext, GetPath(httpContext, _includeQueryInRequestPath), elapsedMs, statusCode));
var (traceId, spanId) = Activity.Current is { } activity ?
(activity.TraceId, activity.SpanId) :
diff --git a/src/Serilog.AspNetCore/Serilog.AspNetCore.csproj b/src/Serilog.AspNetCore/Serilog.AspNetCore.csproj
index ac617d0..a244735 100644
--- a/src/Serilog.AspNetCore/Serilog.AspNetCore.csproj
+++ b/src/Serilog.AspNetCore/Serilog.AspNetCore.csproj
@@ -2,17 +2,13 @@
Serilog support for ASP.NET Core logging
-
- 8.0.3
Microsoft;Serilog Contributors
- net462;netstandard2.0;net6.0;net7.0;net8.0
- true
+ net462;netstandard2.0;netstandard2.1;net8.0;net9.0
serilog;aspnet;aspnetcore
icon.png
https://github.com/serilog/serilog-aspnetcore
Apache-2.0
https://github.com/serilog/serilog-aspnetcore
- git
Serilog
README.md
@@ -24,26 +20,25 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
-
+
-
+
diff --git a/src/Serilog.AspNetCore/images/serilog-extension-nuget.png b/src/Serilog.AspNetCore/images/serilog-extension-nuget.png
deleted file mode 100644
index 1dfe430..0000000
Binary files a/src/Serilog.AspNetCore/images/serilog-extension-nuget.png and /dev/null differ
diff --git a/test/Serilog.AspNetCore.Tests/Serilog.AspNetCore.Tests.csproj b/test/Serilog.AspNetCore.Tests/Serilog.AspNetCore.Tests.csproj
index 446fc77..a0a29df 100644
--- a/test/Serilog.AspNetCore.Tests/Serilog.AspNetCore.Tests.csproj
+++ b/test/Serilog.AspNetCore.Tests/Serilog.AspNetCore.Tests.csproj
@@ -1,7 +1,8 @@
- net8.0
+ net9.0
+ false
@@ -9,10 +10,10 @@
-
-
-
-
+
+
+
+