Skip to content

Commit 2619bc1

Browse files
Merge pull request #207 from TransactionProcessing/task/#204_net_10_upgrade
upgrade to net 10
2 parents 422fee5 + 74b117e commit 2619bc1

21 files changed

Lines changed: 220 additions & 264 deletions

File tree

.github/workflows/createrelease.yml

Lines changed: 136 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [published]
66

77
jobs:
8-
buildlinux:
8+
build:
99
name: "Release"
1010
env:
1111
ASPNETCORE_ENVIRONMENT: "Production"
@@ -15,11 +15,6 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v2.3.4
1717

18-
- name: Install NET 9
19-
uses: actions/setup-dotnet@v4.0.1
20-
with:
21-
dotnet-version: '9.0.x'
22-
2318
- name: Get the version
2419
id: get_version
2520
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
@@ -75,87 +70,91 @@ jobs:
7570
dotnet nuget push Nugets/CallbackHandler.CallbackMessage.DomainEvents.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate
7671
7772
deploystaging:
78-
runs-on: [stagingserver, linux]
79-
needs: buildlinux
73+
runs-on: [stagingserver, windows]
74+
needs: build
8075
environment: staging
8176
name: "Deploy to Staging"
82-
77+
8378
steps:
8479
- name: Download the artifact
8580
uses: actions/download-artifact@v4.1.8
8681
with:
8782
name: callbackhandler
88-
path: /tmp/callbackhandler # Download to a temporary directory
89-
90-
- name: Remove existing service (if applicable)
83+
path: C:\Temp\callbackhandler
84+
85+
- name: Stop and Remove Existing Windows Service (if applicable)
86+
shell: powershell
9187
run: |
92-
SERVICE_NAME="callbackhandler"
93-
if systemctl is-active --quiet "$SERVICE_NAME"; then
94-
echo "Stopping existing service..."
95-
sudo systemctl stop "$SERVICE_NAME"
96-
fi
97-
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
98-
echo "Disabling existing service..."
99-
sudo systemctl disable "$SERVICE_NAME"
100-
fi
101-
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
102-
echo "Removing existing service unit file..."
103-
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
104-
sudo systemctl daemon-reload
105-
fi
106-
88+
$serviceName = "CallbackHandler"
89+
90+
# Stop service if running
91+
if (Get-Service $serviceName -ErrorAction SilentlyContinue) {
92+
Write-Host "Stopping existing service..."
93+
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
94+
95+
# Remove service
96+
Write-Host "Deleting existing service..."
97+
sc.exe delete $serviceName
98+
}
99+
107100
- name: Unzip the files
101+
shell: powershell
108102
run: |
109-
sudo mkdir -p /opt/txnproc/transactionprocessing/callbackhandler
110-
sudo unzip -o /tmp/callbackhandler/callbackhandler.zip -d /opt/txnproc/transactionprocessing/callbackhandler
111-
112-
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
113-
# This assumes it's not already there. If your base image already has it, you can skip this.
103+
$targetPath = "C:\txnproc\CallbackHandler"
104+
105+
if (!(Test-Path $targetPath)) {
106+
New-Item -ItemType Directory -Path $targetPath | Out-Null
107+
}
108+
109+
Expand-Archive -Path "C:\Temp\callbackhandler\callbackhandler.zip" -DestinationPath $targetPath -Force
110+
111+
# Install .NET Runtime if needed. Adjust for the actual version (example: .NET 9 Runtime)
114112
- name: Install .NET Runtime
113+
shell: powershell
115114
run: |
116-
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
117-
# and if you need the SDK or just the runtime.
118-
# This uses Microsoft's package repository for the latest versions.
119-
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
120-
sudo dpkg -i packages-microsoft-prod.deb
121-
rm packages-microsoft-prod.deb
122-
sudo apt update
123-
sudo apt install -y aspnetcore-runtime-9.0
124-
125-
- name: Install and Start as a Linux service
115+
# Check if dotnet 10 is installed
116+
$dotnetVersion = (& dotnet --list-runtimes 2>$null | Select-String "Microsoft\.NETCore\.App 10" | Measure-Object).Count
117+
if ($dotnetVersion -eq 0) {
118+
Write-Host "Installing .NET 10 Runtime..."
119+
120+
$installerUrl = "https://download.visualstudio.microsoft.com/download/pr/6daeb1c2-6c1d-4c34-a4ba-5f12b5e3a884/dotnet-runtime-10.0.0-win-x64.exe"
121+
$installerPath = "dotnet-runtime-10.exe"
122+
123+
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
124+
Start-Process ".\dotnet-runtime-10.exe" -ArgumentList "/quiet" -Wait
125+
126+
Remove-Item ".\dotnet-runtime-10.exe"
127+
}
128+
else {
129+
Write-Host ".NET 10 Runtime already installed."
130+
}
131+
132+
- name: Install and Start Windows Service
133+
shell: powershell
126134
run: |
127-
SERVICE_NAME="callbackhandler"
128-
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
129-
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/callbackhandler"
130-
DLL_NAME="CallbackHandler.dll" # Your application's DLL
131-
SERVICE_DESCRIPTION="Transaction Processing - Callback Handler"
132-
133-
# Create a systemd service file
134-
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
135-
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
136-
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
137-
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
138-
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
139-
# IMPORTANT: Use 'dotnet' to run your DLL
140-
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
141-
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
142-
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
143-
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
144-
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
145-
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
146-
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
147-
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
148-
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
149-
150-
# Reload systemd, enable, and start the service
151-
sudo systemctl daemon-reload
152-
sudo systemctl enable "$SERVICE_NAME"
153-
sudo systemctl start "$SERVICE_NAME"
154-
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
135+
$serviceName = "CallbackHandler"
136+
$serviceDisplay = "Transaction Processing - Callback Handler"
137+
$workingDirectory = "C:\Services\CallbackHandler"
138+
$dllName = "CallbackHandler.dll"
139+
$exePath = "C:\Windows\System32\dotnet.exe"
140+
$fullCmd = "`"$exePath`" `"$workingDirectory\$dllName`""
141+
142+
# Create the service
143+
Write-Host "Creating Windows Service..."
144+
sc.exe create $serviceName binPath= "$fullCmd" start= auto
145+
146+
# Set description
147+
sc.exe description $serviceName "$serviceDisplay"
148+
149+
# Start service
150+
Start-Service -Name $serviceName
151+
152+
# Show status
153+
Get-Service -Name $serviceName
155154
156155
deployproduction:
157-
runs-on: [productionserver, linux]
158-
needs: [buildlinux, deploystaging]
156+
runs-on: [productionserver, windows]
157+
needs: [build, deploystaging]
159158
environment: production
160159
name: "Deploy to Production"
161160

@@ -164,73 +163,77 @@ jobs:
164163
uses: actions/download-artifact@v4.1.8
165164
with:
166165
name: callbackhandler
167-
path: /tmp/callbackhandler # Download to a temporary directory
168-
169-
- name: Remove existing service (if applicable)
166+
path: C:\Temp\callbackhandler
167+
168+
- name: Stop and Remove Existing Windows Service (if applicable)
169+
shell: powershell
170170
run: |
171-
SERVICE_NAME="callbackhandler"
172-
if systemctl is-active --quiet "$SERVICE_NAME"; then
173-
echo "Stopping existing service..."
174-
sudo systemctl stop "$SERVICE_NAME"
175-
fi
176-
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
177-
echo "Disabling existing service..."
178-
sudo systemctl disable "$SERVICE_NAME"
179-
fi
180-
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
181-
echo "Removing existing service unit file..."
182-
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
183-
sudo systemctl daemon-reload
184-
fi
185-
171+
$serviceName = "CallbackHandler"
172+
173+
# Stop service if running
174+
if (Get-Service $serviceName -ErrorAction SilentlyContinue) {
175+
Write-Host "Stopping existing service..."
176+
Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue
177+
178+
# Remove service
179+
Write-Host "Deleting existing service..."
180+
sc.exe delete $serviceName
181+
}
182+
186183
- name: Unzip the files
184+
shell: powershell
187185
run: |
188-
sudo mkdir -p /opt/txnproc/transactionprocessing/callbackhandler
189-
sudo unzip -o /tmp/callbackhandler/callbackhandler.zip -d /opt/txnproc/transactionprocessing/callbackhandler
190-
191-
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
192-
# This assumes it's not already there. If your base image already has it, you can skip this.
186+
$targetPath = "C:\txnproc\CallbackHandler"
187+
188+
if (!(Test-Path $targetPath)) {
189+
New-Item -ItemType Directory -Path $targetPath | Out-Null
190+
}
191+
192+
Expand-Archive -Path "C:\Temp\callbackhandler\callbackhandler.zip" -DestinationPath $targetPath -Force
193+
194+
# Install .NET Runtime if needed. Adjust for the actual version (example: .NET 9 Runtime)
193195
- name: Install .NET Runtime
196+
shell: powershell
194197
run: |
195-
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
196-
# and if you need the SDK or just the runtime.
197-
# This uses Microsoft's package repository for the latest versions.
198-
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
199-
sudo dpkg -i packages-microsoft-prod.deb
200-
rm packages-microsoft-prod.deb
201-
sudo apt update
202-
sudo apt install -y aspnetcore-runtime-9.0
203-
204-
- name: Install and Start as a Linux service
198+
# Check if dotnet 10 is installed
199+
$dotnetVersion = (& dotnet --list-runtimes 2>$null | Select-String "Microsoft\.NETCore\.App 10" | Measure-Object).Count
200+
if ($dotnetVersion -eq 0) {
201+
Write-Host "Installing .NET 10 Runtime..."
202+
203+
$installerUrl = "https://download.visualstudio.microsoft.com/download/pr/6daeb1c2-6c1d-4c34-a4ba-5f12b5e3a884/dotnet-runtime-10.0.0-win-x64.exe"
204+
$installerPath = "dotnet-runtime-10.exe"
205+
206+
Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
207+
Start-Process ".\dotnet-runtime-10.exe" -ArgumentList "/quiet" -Wait
208+
209+
Remove-Item ".\dotnet-runtime-10.exe"
210+
}
211+
else {
212+
Write-Host ".NET 10 Runtime already installed."
213+
}
214+
215+
- name: Install and Start Windows Service
216+
shell: powershell
205217
run: |
206-
SERVICE_NAME="callbackhandler"
207-
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
208-
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/callbackhandler"
209-
DLL_NAME="CallbackHandler.dll" # Your application's DLL
210-
SERVICE_DESCRIPTION="Transaction Processing - Callback Handler"
211-
212-
# Create a systemd service file
213-
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
214-
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
215-
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
216-
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
217-
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
218-
# IMPORTANT: Use 'dotnet' to run your DLL
219-
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
220-
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
221-
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
222-
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
223-
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
224-
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
225-
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
226-
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
227-
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
228-
229-
# Reload systemd, enable, and start the service
230-
sudo systemctl daemon-reload
231-
sudo systemctl enable "$SERVICE_NAME"
232-
sudo systemctl start "$SERVICE_NAME"
233-
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification
218+
$serviceName = "CallbackHandler"
219+
$serviceDisplay = "Transaction Processing - Callback Handler"
220+
$workingDirectory = "C:\Services\CallbackHandler"
221+
$dllName = "CallbackHandler.dll"
222+
$exePath = "C:\Windows\System32\dotnet.exe"
223+
$fullCmd = "`"$exePath`" `"$workingDirectory\$dllName`""
224+
225+
# Create the service
226+
Write-Host "Creating Windows Service..."
227+
sc.exe create $serviceName binPath= "$fullCmd" start= auto
228+
229+
# Set description
230+
sc.exe description $serviceName "$serviceDisplay"
231+
232+
# Start service
233+
Start-Service -Name $serviceName
234+
235+
# Show status
236+
Get-Service -Name $serviceName
234237
235238
buildwindows:
236239
name: "Windows Release"

.github/workflows/nightlybuild.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v2.3.4
1818

19-
- name: Install NET 9
20-
uses: actions/setup-dotnet@v4.0.1
21-
with:
22-
dotnet-version: '9.0.x'
23-
2419
- name: Set Up Variables
2520
run: echo "action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
2621

.github/workflows/pullrequest.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v2.3.4
1818

19-
- name: Install NET 9
20-
uses: actions/setup-dotnet@v4.0.1
21-
with:
22-
dotnet-version: '9.0.x'
23-
2419
- name: Restore Nuget Packages
2520
run: dotnet restore CallbackHandler.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
2621

.github/workflows/pushtomain.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22-
- name: Install NET 9
23-
uses: actions/setup-dotnet@v4.0.1
24-
with:
25-
dotnet-version: '9.0.x'
26-
2722
- name: Restore Nuget Packages
2823
run: dotnet restore CallbackHandler.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}
2924

CallbackHander.Testing/CallbackHander.Testing.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<DebugType>None</DebugType>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1111
<PackageReference Include="xunit" Version="2.9.3" />
1212
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

CallbackHandler.BusinessLogic.Tests/CallbackHandler.BusinessLogic.Tests.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<DebugType>None</DebugType>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1111
<PackageReference Include="Moq" Version="4.20.72" />
12-
<PackageReference Include="Shared.EventStore" Version="2025.11.11" />
12+
<PackageReference Include="Shared.EventStore" Version="2025.12.1" />
1313
<PackageReference Include="Shouldly" Version="4.3.0" />
1414
<PackageReference Include="xunit" Version="2.9.3" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">

0 commit comments

Comments
 (0)