From d4df05504720570fd3599f7eea29a3627bed5bd8 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Sat, 6 Dec 2025 12:58:25 +0000 Subject: [PATCH 1/2] upgrade to net 10 --- .github/workflows/createrelease.yml | 269 +++++++++--------- .github/workflows/nightlybuild.yml | 5 - .github/workflows/pullrequest.yml | 5 - .github/workflows/pushtomain.yml | 5 - .../CallbackHander.Testing.csproj | 4 +- ...CallbackHandler.BusinessLogic.Tests.csproj | 6 +- .../CallbackHandler.BusinessLogic.csproj | 10 +- ...andler.CallbackMessage.DomainEvents.csproj | 6 +- ...dler.CallbackMessageAggregate.Tests.csproj | 6 +- ...ackHandler.CallbackMessageAggregate.csproj | 8 +- ...CallbackHandler.DataTransferObjects.csproj | 2 +- .../CallbackHandler.IntegrationTests.csproj | 14 +- .../CallbackHandler.Tests.csproj | 8 +- .../Bootstrapper/MiddlewareRegistry.cs | 64 ++--- .../Bootstrapper/RepositoryRegistry.cs | 6 +- CallbackHandler/CallbackHandler.csproj | 26 +- CallbackHandler/Common/Extensions.cs | 6 +- .../Common/SwaggerDefaultValues.cs | 5 +- CallbackHandler/Startup.cs | 23 -- .../CallbackHandlers.Models.csproj | 2 +- 20 files changed, 218 insertions(+), 262 deletions(-) diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index efb4e06..b756bb5 100644 --- a/.github/workflows/createrelease.yml +++ b/.github/workflows/createrelease.yml @@ -5,7 +5,7 @@ on: types: [published] jobs: - buildlinux: + build: name: "Release" env: ASPNETCORE_ENVIRONMENT: "Production" @@ -15,11 +15,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Get the version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} @@ -75,87 +70,91 @@ jobs: dotnet nuget push Nugets/CallbackHandler.CallbackMessage.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate deploystaging: - runs-on: [stagingserver, linux] - needs: buildlinux + runs-on: [stagingserver, windows] + needs: build environment: staging name: "Deploy to Staging" - + steps: - name: Download the artifact uses: actions/download-artifact@v4.1.8 with: name: callbackhandler - path: /tmp/callbackhandler # Download to a temporary directory - - - name: Remove existing service (if applicable) + path: C:\Temp\callbackhandler + + - name: Stop and Remove Existing Windows Service (if applicable) + shell: powershell run: | - SERVICE_NAME="callbackhandler" - if systemctl is-active --quiet "$SERVICE_NAME"; then - echo "Stopping existing service..." - sudo systemctl stop "$SERVICE_NAME" - fi - if systemctl is-enabled --quiet "$SERVICE_NAME"; then - echo "Disabling existing service..." - sudo systemctl disable "$SERVICE_NAME" - fi - if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then - echo "Removing existing service unit file..." - sudo rm "/etc/systemd/system/${SERVICE_NAME}.service" - sudo systemctl daemon-reload - fi - + $serviceName = "CallbackHandler" + + # Stop service if running + if (Get-Service $serviceName -ErrorAction SilentlyContinue) { + Write-Host "Stopping existing service..." + Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue + + # Remove service + Write-Host "Deleting existing service..." + sc.exe delete $serviceName + } + - name: Unzip the files + shell: powershell run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/callbackhandler - sudo unzip -o /tmp/callbackhandler/callbackhandler.zip -d /opt/txnproc/transactionprocessing/callbackhandler - - # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server - # This assumes it's not already there. If your base image already has it, you can skip this. + $targetPath = "C:\txnproc\CallbackHandler" + + if (!(Test-Path $targetPath)) { + New-Item -ItemType Directory -Path $targetPath | Out-Null + } + + Expand-Archive -Path "C:\Temp\callbackhandler\callbackhandler.zip" -DestinationPath $targetPath -Force + + # Install .NET Runtime if needed. Adjust for the actual version (example: .NET 9 Runtime) - name: Install .NET Runtime + shell: powershell run: | - # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0) - # and if you need the SDK or just the runtime. - # This uses Microsoft's package repository for the latest versions. - wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt update - sudo apt install -y aspnetcore-runtime-9.0 - - - name: Install and Start as a Linux service + # Check if dotnet 10 is installed + $dotnetVersion = (& dotnet --list-runtimes 2>$null | Select-String "Microsoft\.NETCore\.App 10" | Measure-Object).Count + if ($dotnetVersion -eq 0) { + Write-Host "Installing .NET 10 Runtime..." + + $installerUrl = "https://download.visualstudio.microsoft.com/download/pr/6daeb1c2-6c1d-4c34-a4ba-5f12b5e3a884/dotnet-runtime-10.0.0-win-x64.exe" + $installerPath = "dotnet-runtime-10.exe" + + Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath + Start-Process ".\dotnet-runtime-10.exe" -ArgumentList "/quiet" -Wait + + Remove-Item ".\dotnet-runtime-10.exe" + } + else { + Write-Host ".NET 10 Runtime already installed." + } + + - name: Install and Start Windows Service + shell: powershell run: | - SERVICE_NAME="callbackhandler" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/callbackhandler" - DLL_NAME="CallbackHandler.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Callback Handler" - - # Create a systemd service file - echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service - echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - # IMPORTANT: Use 'dotnet' to run your DLL - echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user - echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group - echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - - # Reload systemd, enable, and start the service - sudo systemctl daemon-reload - sudo systemctl enable "$SERVICE_NAME" - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification + $serviceName = "CallbackHandler" + $serviceDisplay = "Transaction Processing - Callback Handler" + $workingDirectory = "C:\Services\CallbackHandler" + $dllName = "CallbackHandler.dll" + $exePath = "C:\Windows\System32\dotnet.exe" + $fullCmd = "`"$exePath`" `"$workingDirectory\$dllName`"" + + # Create the service + Write-Host "Creating Windows Service..." + sc.exe create $serviceName binPath= "$fullCmd" start= auto + + # Set description + sc.exe description $serviceName "$serviceDisplay" + + # Start service + Start-Service -Name $serviceName + + # Show status + Get-Service -Name $serviceName deployproduction: - runs-on: [productionserver, linux] - needs: [buildlinux, deploystaging] + runs-on: [productionserver, windows] + needs: [build, deploystaging] environment: production name: "Deploy to Production" @@ -164,73 +163,77 @@ jobs: uses: actions/download-artifact@v4.1.8 with: name: callbackhandler - path: /tmp/callbackhandler # Download to a temporary directory - - - name: Remove existing service (if applicable) + path: C:\Temp\callbackhandler + + - name: Stop and Remove Existing Windows Service (if applicable) + shell: powershell run: | - SERVICE_NAME="callbackhandler" - if systemctl is-active --quiet "$SERVICE_NAME"; then - echo "Stopping existing service..." - sudo systemctl stop "$SERVICE_NAME" - fi - if systemctl is-enabled --quiet "$SERVICE_NAME"; then - echo "Disabling existing service..." - sudo systemctl disable "$SERVICE_NAME" - fi - if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then - echo "Removing existing service unit file..." - sudo rm "/etc/systemd/system/${SERVICE_NAME}.service" - sudo systemctl daemon-reload - fi - + $serviceName = "CallbackHandler" + + # Stop service if running + if (Get-Service $serviceName -ErrorAction SilentlyContinue) { + Write-Host "Stopping existing service..." + Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue + + # Remove service + Write-Host "Deleting existing service..." + sc.exe delete $serviceName + } + - name: Unzip the files + shell: powershell run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/callbackhandler - sudo unzip -o /tmp/callbackhandler/callbackhandler.zip -d /opt/txnproc/transactionprocessing/callbackhandler - - # IMPORTANT: Add a step to ensure the .NET runtime is installed on the server - # This assumes it's not already there. If your base image already has it, you can skip this. + $targetPath = "C:\txnproc\CallbackHandler" + + if (!(Test-Path $targetPath)) { + New-Item -ItemType Directory -Path $targetPath | Out-Null + } + + Expand-Archive -Path "C:\Temp\callbackhandler\callbackhandler.zip" -DestinationPath $targetPath -Force + + # Install .NET Runtime if needed. Adjust for the actual version (example: .NET 9 Runtime) - name: Install .NET Runtime + shell: powershell run: | - # Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0) - # and if you need the SDK or just the runtime. - # This uses Microsoft's package repository for the latest versions. - wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - rm packages-microsoft-prod.deb - sudo apt update - sudo apt install -y aspnetcore-runtime-9.0 - - - name: Install and Start as a Linux service + # Check if dotnet 10 is installed + $dotnetVersion = (& dotnet --list-runtimes 2>$null | Select-String "Microsoft\.NETCore\.App 10" | Measure-Object).Count + if ($dotnetVersion -eq 0) { + Write-Host "Installing .NET 10 Runtime..." + + $installerUrl = "https://download.visualstudio.microsoft.com/download/pr/6daeb1c2-6c1d-4c34-a4ba-5f12b5e3a884/dotnet-runtime-10.0.0-win-x64.exe" + $installerPath = "dotnet-runtime-10.exe" + + Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath + Start-Process ".\dotnet-runtime-10.exe" -ArgumentList "/quiet" -Wait + + Remove-Item ".\dotnet-runtime-10.exe" + } + else { + Write-Host ".NET 10 Runtime already installed." + } + + - name: Install and Start Windows Service + shell: powershell run: | - SERVICE_NAME="callbackhandler" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/callbackhandler" - DLL_NAME="CallbackHandler.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Callback Handler" - - # Create a systemd service file - echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service - echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - # IMPORTANT: Use 'dotnet' to run your DLL - echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user - echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group - echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example - echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service - - # Reload systemd, enable, and start the service - sudo systemctl daemon-reload - sudo systemctl enable "$SERVICE_NAME" - sudo systemctl start "$SERVICE_NAME" - sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification + $serviceName = "CallbackHandler" + $serviceDisplay = "Transaction Processing - Callback Handler" + $workingDirectory = "C:\Services\CallbackHandler" + $dllName = "CallbackHandler.dll" + $exePath = "C:\Windows\System32\dotnet.exe" + $fullCmd = "`"$exePath`" `"$workingDirectory\$dllName`"" + + # Create the service + Write-Host "Creating Windows Service..." + sc.exe create $serviceName binPath= "$fullCmd" start= auto + + # Set description + sc.exe description $serviceName "$serviceDisplay" + + # Start service + Start-Service -Name $serviceName + + # Show status + Get-Service -Name $serviceName buildwindows: name: "Windows Release" diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index 07fbcbc..0626655 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -16,11 +16,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Set Up Variables run: echo "action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 8c83909..b6670da 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -16,11 +16,6 @@ jobs: steps: - uses: actions/checkout@v2.3.4 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Restore Nuget Packages run: dotnet restore CallbackHandler.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/.github/workflows/pushtomain.yml b/.github/workflows/pushtomain.yml index 0b47a52..2a5c22b 100644 --- a/.github/workflows/pushtomain.yml +++ b/.github/workflows/pushtomain.yml @@ -19,11 +19,6 @@ jobs: with: fetch-depth: 0 - - name: Install NET 9 - uses: actions/setup-dotnet@v4.0.1 - with: - dotnet-version: '9.0.x' - - name: Restore Nuget Packages run: dotnet restore CallbackHandler.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/CallbackHander.Testing/CallbackHander.Testing.csproj b/CallbackHander.Testing/CallbackHander.Testing.csproj index c1f8dc9..436b70b 100644 --- a/CallbackHander.Testing/CallbackHander.Testing.csproj +++ b/CallbackHander.Testing/CallbackHander.Testing.csproj @@ -1,13 +1,13 @@  - net9.0 + net10.0 None false - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CallbackHandler.BusinessLogic.Tests/CallbackHandler.BusinessLogic.Tests.csproj b/CallbackHandler.BusinessLogic.Tests/CallbackHandler.BusinessLogic.Tests.csproj index d94d81d..63bc191 100644 --- a/CallbackHandler.BusinessLogic.Tests/CallbackHandler.BusinessLogic.Tests.csproj +++ b/CallbackHandler.BusinessLogic.Tests/CallbackHandler.BusinessLogic.Tests.csproj @@ -1,15 +1,15 @@  - net9.0 + net10.0 None false - + - + diff --git a/CallbackHandler.BusinessLogic/CallbackHandler.BusinessLogic.csproj b/CallbackHandler.BusinessLogic/CallbackHandler.BusinessLogic.csproj index 3a98bd0..0e65c63 100644 --- a/CallbackHandler.BusinessLogic/CallbackHandler.BusinessLogic.csproj +++ b/CallbackHandler.BusinessLogic/CallbackHandler.BusinessLogic.csproj @@ -1,13 +1,13 @@  - net9.0 + net10.0 - - - - + + + + diff --git a/CallbackHandler.CallbackMessage.DomainEvents/CallbackHandler.CallbackMessage.DomainEvents.csproj b/CallbackHandler.CallbackMessage.DomainEvents/CallbackHandler.CallbackMessage.DomainEvents.csproj index 0eb2dda..fb58779 100644 --- a/CallbackHandler.CallbackMessage.DomainEvents/CallbackHandler.CallbackMessage.DomainEvents.csproj +++ b/CallbackHandler.CallbackMessage.DomainEvents/CallbackHandler.CallbackMessage.DomainEvents.csproj @@ -1,11 +1,11 @@  - net9.0 + net10.0 None - - + + \ No newline at end of file diff --git a/CallbackHandler.CallbackMessageAggregate.Tests/CallbackHandler.CallbackMessageAggregate.Tests.csproj b/CallbackHandler.CallbackMessageAggregate.Tests/CallbackHandler.CallbackMessageAggregate.Tests.csproj index bf0207b..664456c 100644 --- a/CallbackHandler.CallbackMessageAggregate.Tests/CallbackHandler.CallbackMessageAggregate.Tests.csproj +++ b/CallbackHandler.CallbackMessageAggregate.Tests/CallbackHandler.CallbackMessageAggregate.Tests.csproj @@ -1,14 +1,14 @@  - net9.0 + net10.0 None false - - + + diff --git a/CallbackHandler.CallbackMessageAggregate/CallbackHandler.CallbackMessageAggregate.csproj b/CallbackHandler.CallbackMessageAggregate/CallbackHandler.CallbackMessageAggregate.csproj index a30776d..ed05f6e 100644 --- a/CallbackHandler.CallbackMessageAggregate/CallbackHandler.CallbackMessageAggregate.csproj +++ b/CallbackHandler.CallbackMessageAggregate/CallbackHandler.CallbackMessageAggregate.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 @@ -10,8 +10,8 @@ - - - + + + \ No newline at end of file diff --git a/CallbackHandler.DataTransferObjects/CallbackHandler.DataTransferObjects.csproj b/CallbackHandler.DataTransferObjects/CallbackHandler.DataTransferObjects.csproj index ca68420..47d2b0f 100644 --- a/CallbackHandler.DataTransferObjects/CallbackHandler.DataTransferObjects.csproj +++ b/CallbackHandler.DataTransferObjects/CallbackHandler.DataTransferObjects.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 None diff --git a/CallbackHandler.IntegrationTests/CallbackHandler.IntegrationTests.csproj b/CallbackHandler.IntegrationTests/CallbackHandler.IntegrationTests.csproj index 2d27b3d..5af009b 100644 --- a/CallbackHandler.IntegrationTests/CallbackHandler.IntegrationTests.csproj +++ b/CallbackHandler.IntegrationTests/CallbackHandler.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable @@ -9,14 +9,14 @@ - - - + + + - - - + + + diff --git a/CallbackHandler.Tests/CallbackHandler.Tests.csproj b/CallbackHandler.Tests/CallbackHandler.Tests.csproj index 7de5137..e50151d 100644 --- a/CallbackHandler.Tests/CallbackHandler.Tests.csproj +++ b/CallbackHandler.Tests/CallbackHandler.Tests.csproj @@ -1,16 +1,16 @@  - net9.0 + net10.0 false - - - + + + diff --git a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs index 4872cb8..005ed29 100644 --- a/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs +++ b/CallbackHandler/Bootstrapper/MiddlewareRegistry.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.Logging; +using KurrentDB.Client; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi; namespace CallbackHandler.Bootstrapper; @@ -8,7 +10,6 @@ namespace CallbackHandler.Bootstrapper; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; -using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Shared.EventStore.Extensions; @@ -29,7 +30,7 @@ public class MiddlewareRegistry :ServiceRegistry public MiddlewareRegistry() { String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString"); - EventStoreClientSettings eventStoreSettings = EventStoreClientSettings.Create(connectionString); + KurrentDBClientSettings eventStoreSettings = KurrentDBClientSettings.Create(connectionString); this.AddHealthChecks().AddEventStore(eventStoreSettings, userCredentials: eventStoreSettings.DefaultCredentials, @@ -64,47 +65,34 @@ public MiddlewareRegistry() c.IncludeXmlComments(fileInfo.FullName); } - }); - this.AddSwaggerExamples(); + }); + this.AddSwaggerExamples(); - this.AddControllers().AddNewtonsoftJson(options => - { - options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - options.SerializerSettings.TypeNameHandling = TypeNameHandling.None; - options.SerializerSettings.Formatting = Formatting.Indented; - options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; - options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); - }); - - Assembly assembly = this.GetType().GetTypeInfo().Assembly; - this.AddMvcCore().AddApplicationPart(assembly).AddControllersAsServices(); + this.AddControllers().AddNewtonsoftJson(options => + { + options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + options.SerializerSettings.TypeNameHandling = TypeNameHandling.None; + options.SerializerSettings.Formatting = Formatting.Indented; + options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; + options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + }); - bool logRequests = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogRequests", true); - bool logResponses = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogResponses", true); - LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning); + Assembly assembly = this.GetType().GetTypeInfo().Assembly; + this.AddMvcCore().AddApplicationPart(assembly).AddControllersAsServices(); - RequestResponseMiddlewareLoggingConfig config = - new(middlewareLogLevel, logRequests, logResponses); + bool logRequests = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogRequests", true); + bool logResponses = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "LogResponses", true); + LogLevel middlewareLogLevel = ConfigurationReader.GetValueOrDefault("MiddlewareLogging", "MiddlewareLogLevel", LogLevel.Warning); - this.AddSingleton(config); + RequestResponseMiddlewareLoggingConfig config = + new(middlewareLogLevel, logRequests, logResponses); - this.ConfigureHttpJsonOptions(options => - { - options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy(); - options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer - }); - } + this.AddSingleton(config); - public class SnakeCaseNamingPolicy : JsonNamingPolicy - { - public override string ConvertName(string name) + this.ConfigureHttpJsonOptions(options => { - // simple PascalCase to snake_case - return string.Concat( - name.Select((c, i) => - i > 0 && char.IsUpper(c) ? "_" + char.ToLower(c) : char.ToLower(c).ToString() - ) - ); - } + options.SerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy(); + options.SerializerOptions.PropertyNameCaseInsensitive = true; // optional, but safer + }); } } diff --git a/CallbackHandler/Bootstrapper/RepositoryRegistry.cs b/CallbackHandler/Bootstrapper/RepositoryRegistry.cs index 6370f61..e5d4017 100644 --- a/CallbackHandler/Bootstrapper/RepositoryRegistry.cs +++ b/CallbackHandler/Bootstrapper/RepositoryRegistry.cs @@ -24,10 +24,10 @@ public RepositoryRegistry() String connectionString = Startup.Configuration.GetValue("EventStoreSettings:ConnectionString"); - this.AddEventStoreProjectionManagementClient(connectionString); - this.AddEventStorePersistentSubscriptionsClient(connectionString); + this.AddKurrentDBProjectionManagementClient(connectionString); + this.AddKurrentDBPersistentSubscriptionsClient(connectionString); - this.AddEventStoreClient(connectionString); + this.AddKurrentDBClient(connectionString); this.AddSingleton, DomainEventFactory>(); } diff --git a/CallbackHandler/CallbackHandler.csproj b/CallbackHandler/CallbackHandler.csproj index c4a47de..9925208 100644 --- a/CallbackHandler/CallbackHandler.csproj +++ b/CallbackHandler/CallbackHandler.csproj @@ -1,28 +1,28 @@  - net9.0 + net10.0 Linux - + - + - - + + - - - - - - - - + + + + + + + + diff --git a/CallbackHandler/Common/Extensions.cs b/CallbackHandler/Common/Extensions.cs index a2901cb..e2d40c8 100644 --- a/CallbackHandler/Common/Extensions.cs +++ b/CallbackHandler/Common/Extensions.cs @@ -1,4 +1,6 @@ -namespace CallbackHandler.Common; +using KurrentDB.Client; + +namespace CallbackHandler.Common; using System; using System.Diagnostics.CodeAnalysis; @@ -12,7 +14,7 @@ public static class Extensions public static IServiceCollection AddInSecureEventStoreClient(this IServiceCollection services, Uri address, Func? createHttpMessageHandler = null) { - return services.AddEventStoreClient((Action)(options => { + return services.AddKurrentDBClient((Action)(options => { options.ConnectivitySettings.Address = address; options.ConnectivitySettings.Insecure = true; options.CreateHttpMessageHandler = createHttpMessageHandler; diff --git a/CallbackHandler/Common/SwaggerDefaultValues.cs b/CallbackHandler/Common/SwaggerDefaultValues.cs index 6c83f8c..ca0fe01 100644 --- a/CallbackHandler/Common/SwaggerDefaultValues.cs +++ b/CallbackHandler/Common/SwaggerDefaultValues.cs @@ -1,9 +1,10 @@ -namespace CallbackHandler.Common +using Microsoft.OpenApi; + +namespace CallbackHandler.Common { using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.AspNetCore.Mvc.ApiExplorer; - using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; [ExcludeFromCodeCoverage] diff --git a/CallbackHandler/Startup.cs b/CallbackHandler/Startup.cs index 2397603..2a42686 100644 --- a/CallbackHandler/Startup.cs +++ b/CallbackHandler/Startup.cs @@ -1,45 +1,22 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using CallbackHandler.Endpoints; namespace CallbackHandler { using Bootstrapper; - using BusinessLogic.Common; - using BusinessLogic.RequestHandler; - using BusinessLogic.Requests; - using Common; - using EventStore.Client; using HealthChecks.UI.Client; using Lamar; - using MediatR; using Microsoft.AspNetCore.Diagnostics.HealthChecks; - using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; - using Microsoft.OpenApi.Models; - using Newtonsoft.Json; - using Newtonsoft.Json.Serialization; - using NLog.Extensions.Logging; - using Shared.DomainDrivenDesign.EventSourcing; using Shared.EventStore.Aggregate; - using Shared.EventStore.EventStore; - using Shared.EventStore.Extensions; using Shared.Extensions; using Shared.General; using Shared.Logger; using Shared.Middleware; - using Swashbuckle.AspNetCore.Filters; using System.Diagnostics.CodeAnalysis; - using System.IO; - using System.Net.Http; - using System.Reflection; using ILogger = Microsoft.Extensions.Logging.ILogger; [ExcludeFromCodeCoverage] diff --git a/CallbackHandlers.Models/CallbackHandlers.Models.csproj b/CallbackHandlers.Models/CallbackHandlers.Models.csproj index 2d908e7..4a974a7 100644 --- a/CallbackHandlers.Models/CallbackHandlers.Models.csproj +++ b/CallbackHandlers.Models/CallbackHandlers.Models.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 From 74b117e0fbe665b3060581b5b56eb0432a28edcd Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Sat, 6 Dec 2025 13:08:41 +0000 Subject: [PATCH 2/2] :| --- CallbackHandler/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CallbackHandler/Dockerfile b/CallbackHandler/Dockerfile index 7cc52bb..405651f 100644 --- a/CallbackHandler/Dockerfile +++ b/CallbackHandler/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY ["CallbackHandler/NuGet.Config", "."] COPY ["CallbackHandler/CallbackHandler.csproj", "CallbackHandler/"]