diff --git a/.github/workflows/buildwindowsimage.yml b/.github/workflows/buildwindowsimage.yml index 9fca846..51ca208 100644 --- a/.github/workflows/buildwindowsimage.yml +++ b/.github/workflows/buildwindowsimage.yml @@ -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 uses: battila7/get-version-action@v2 diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml index 372f635..1dca87d 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\//} @@ -55,7 +50,7 @@ jobs: - name: Publish API if: ${{ github.event.release.prerelease == false }} - run: dotnet publish "EstateReportingAPI\EstateReportingAPI.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained + run: dotnet publish "EstateReportingAPI\EstateReportingAPI.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained - name: Build Release Package run: | @@ -75,8 +70,8 @@ jobs: dotnet nuget push Nugets/EstateReportingAPI.Client.${{ 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" @@ -85,77 +80,31 @@ jobs: uses: actions/download-artifact@v4.1.8 with: name: estatereportingapi - path: /tmp/estatereportingapi # Download to a temporary directory - - name: Remove existing service (if applicable) + - name: Remove existing Windows service run: | - SERVICE_NAME="estatereportingapi" - 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 = "Transaction Processing - Estate Reporting" + # Check if the service exists + if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { + Stop-Service -Name $serviceName + sc.exe delete $serviceName + } - name: Unzip the files run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/estatereportingapi - sudo unzip -o /tmp/estatereportingapi/estatereportingapi.zip -d /opt/txnproc/transactionprocessing/estatereportingapi + Expand-Archive -Path estatereportingapi.zip -DestinationPath "C:\txnproc\transactionprocessing\estatereportingapi" -Force - # 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. - - name: Install .NET Runtime + - name: Install as a Windows service 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 - run: | - SERVICE_NAME="estatereportingapi" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/estatereportingapi" - DLL_NAME="EstateReportingAPI.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Estate Reporting API" - - # 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 = "Transaction Processing - Estate Reporting" + $servicePath = "C:\txnproc\transactionprocessing\estatereportingapi\EstateReportingAPI.exe" + + New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic + Start-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,70 +113,24 @@ jobs: uses: actions/download-artifact@v4.1.8 with: name: estatereportingapi - path: /tmp/estatereportingapi # Download to a temporary directory - - name: Remove existing service (if applicable) + - name: Remove existing Windows service run: | - SERVICE_NAME="estatereportingapi" - 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 = "Transaction Processing - Estate Reporting" + # Check if the service exists + if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { + Stop-Service -Name $serviceName + sc.exe delete $serviceName + } - name: Unzip the files run: | - sudo mkdir -p /opt/txnproc/transactionprocessing/estatereportingapi - sudo unzip -o /tmp/securityservice/estatereportingapi.zip -d /opt/txnproc/transactionprocessing/estatereportingapi - - # 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. - - name: Install .NET Runtime - 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 + Expand-Archive -Path estatereportingapi.zip -DestinationPath "C:\txnproc\transactionprocessing\estatereportingapi" -Force - - name: Install and Start as a Linux service + - name: Install as a Windows service run: | - SERVICE_NAME="estatereportingapi" - # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files - WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/estatereportingapi" - DLL_NAME="EstateReportingAPI.dll" # Your application's DLL - SERVICE_DESCRIPTION="Transaction Processing - Estate Reporting API" - - # 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 = "Transaction Processing - Estate Reporting" + $servicePath = "C:\txnproc\transactionprocessing\estatereportingapi\EstateReportingAPI.exe" + + New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic + Start-Service -Name $serviceName diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index 032aeb2..ebb3c71 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 @@ -57,7 +52,7 @@ jobs: coverage-reports: ./lcov.info files: ./lcov2.info - - uses: actions/upload-artifact@v4.4.0 + - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: tracelogs diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 83e9c02..863444f 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -15,12 +15,7 @@ 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 EstateReportingAPI.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} @@ -36,7 +31,7 @@ jobs: run: | dotnet test "EstateReportingAPI.IntegrationTests\EstateReportingAPI.IntegrationTests.csproj" - - uses: actions/upload-artifact@v4.4.0 + - uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: tracelogs diff --git a/.github/workflows/pushtomaster.yml b/.github/workflows/pushtomaster.yml index a327928..f0680ee 100644 --- a/.github/workflows/pushtomaster.yml +++ b/.github/workflows/pushtomaster.yml @@ -18,11 +18,6 @@ jobs: - uses: actions/checkout@v2.3.4 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 EstateReportingAPI.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} diff --git a/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj b/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj index 240b870..544696d 100644 --- a/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj +++ b/EstateReportingAPI.BusinessLogic/EstateReportingAPI.BusinessLogic.csproj @@ -1,15 +1,15 @@  - net9.0 + net10.0 enable enable - - - + + + diff --git a/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj b/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj index 82f667c..430c21f 100644 --- a/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj +++ b/EstateReportingAPI.Client/EstateReportingAPI.Client.csproj @@ -1,15 +1,15 @@  - net9.0 + net10.0 $(TargetsForTfmSpecificBuildOutput);IncludeP2PAssets enable - + - + diff --git a/EstateReportingAPI.DataTrasferObjects/EstateReportingAPI.DataTransferObjects.csproj b/EstateReportingAPI.DataTrasferObjects/EstateReportingAPI.DataTransferObjects.csproj index 63e3607..b7e5a0a 100644 --- a/EstateReportingAPI.DataTrasferObjects/EstateReportingAPI.DataTransferObjects.csproj +++ b/EstateReportingAPI.DataTrasferObjects/EstateReportingAPI.DataTransferObjects.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable None diff --git a/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj b/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj index 3a70110..afd025a 100644 --- a/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj +++ b/EstateReportingAPI.IntegrationTests/EstateReportingAPI.IntegrationTests.csproj @@ -1,16 +1,17 @@  - net9.0 + net10.0 Full false + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,13 +22,13 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + - - - + + + diff --git a/EstateReportingAPI.IntegrationTests/FactTransactionsControllerTests.cs b/EstateReportingAPI.IntegrationTests/FactTransactionsControllerTests.cs index 7d21fa9..e6cd1cd 100644 --- a/EstateReportingAPI.IntegrationTests/FactTransactionsControllerTests.cs +++ b/EstateReportingAPI.IntegrationTests/FactTransactionsControllerTests.cs @@ -17,7 +17,6 @@ namespace EstateReportingAPI.IntegrationTests; using DataTrasferObjects; using EstateReportingAPI.DataTransferObjects; using EstateReportingAPI.Models; -using Microsoft.OpenApi.Services; using Newtonsoft.Json; using Shouldly; using Xunit; diff --git a/EstateReportingAPI.IntegrationTests/xunit.runner.json b/EstateReportingAPI.IntegrationTests/xunit.runner.json index 0dbddf9..29ceb58 100644 --- a/EstateReportingAPI.IntegrationTests/xunit.runner.json +++ b/EstateReportingAPI.IntegrationTests/xunit.runner.json @@ -1,5 +1,4 @@ { "maxParallelThreads": 3, - "parallelizeTestCollections": true - + "parallelizeTestCollections": true } \ No newline at end of file diff --git a/EstateReportingAPI.Models/EstateReportingAPI.Models.csproj b/EstateReportingAPI.Models/EstateReportingAPI.Models.csproj index 279ad60..afb3987 100644 --- a/EstateReportingAPI.Models/EstateReportingAPI.Models.csproj +++ b/EstateReportingAPI.Models/EstateReportingAPI.Models.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable None diff --git a/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj b/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj index fddf6f8..8f6f4a4 100644 --- a/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj +++ b/EstateReportingAPI.Tests/EstateReportingAPI.Tests.csproj @@ -1,24 +1,25 @@  - net9.0 + net10.0 Full false - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs b/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs index 2e8714b..6e13dfb 100644 --- a/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs +++ b/EstateReportingAPI/Bootstrapper/MiddlewareRegistry.cs @@ -1,4 +1,5 @@ -using Shared.Middleware; +using Microsoft.OpenApi; +using Shared.Middleware; namespace EstateReportingAPI.Bootstrapper{ using System.Diagnostics.CodeAnalysis; @@ -9,7 +10,6 @@ namespace EstateReportingAPI.Bootstrapper{ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.IdentityModel.Tokens; - using Microsoft.OpenApi.Models; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Shared.General; diff --git a/EstateReportingAPI/Common/SwaggerDefaultValues.cs b/EstateReportingAPI/Common/SwaggerDefaultValues.cs index b001b35..79f6998 100644 --- a/EstateReportingAPI/Common/SwaggerDefaultValues.cs +++ b/EstateReportingAPI/Common/SwaggerDefaultValues.cs @@ -1,9 +1,10 @@ -namespace EstateReportingAPI.Common +using Microsoft.OpenApi; + +namespace EstateReportingAPI.Common { using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.AspNetCore.Mvc.ApiExplorer; - using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; /// diff --git a/EstateReportingAPI/Dockerfile b/EstateReportingAPI/Dockerfile index 2d4f2ea..2ead79c 100644 --- a/EstateReportingAPI/Dockerfile +++ b/EstateReportingAPI/Dockerfile @@ -1,7 +1,7 @@ FROM stuartferguson/txnprocbase AS base WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY ["EstateReportingAPI/NuGet.Config", "."] COPY ["EstateReportingAPI/EstateReportingAPI.csproj", "EstateReportingAPI/"] diff --git a/EstateReportingAPI/Dockerfilewindows b/EstateReportingAPI/Dockerfilewindows index f429699..413d263 100644 --- a/EstateReportingAPI/Dockerfilewindows +++ b/EstateReportingAPI/Dockerfilewindows @@ -2,7 +2,7 @@ FROM stuartferguson/txnprocbasewindows AS base USER ContainerAdministrator WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0-windowsservercore-ltsc2022 AS build WORKDIR /src COPY ["EstateReportingAPI/NuGet.Config", "."] COPY ["EstateReportingAPI/EstateReportingAPI.csproj", "EstateReportingAPI/"] diff --git a/EstateReportingAPI/EstateReportingAPI.csproj b/EstateReportingAPI/EstateReportingAPI.csproj index 8c5fdef..b950241 100644 --- a/EstateReportingAPI/EstateReportingAPI.csproj +++ b/EstateReportingAPI/EstateReportingAPI.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable 3ed94abc-423c-49b8-ac5d-edc80e1eaa74 @@ -10,32 +10,32 @@ - + - - - + + + - - + + - - - - - - - - - + + + + + + + + +