Skip to content

Commit e86d524

Browse files
author
rhamlett_microsoft
committed
Added .NET 8 Build for diagnostics compatibility
1 parent 9e6df2c commit e86d524

5 files changed

Lines changed: 102 additions & 18 deletions

File tree

.github/workflows/azure-deploy.yml

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,98 @@ on:
55
branches:
66
- main
77
workflow_dispatch:
8+
inputs:
9+
deploy_net8:
10+
description: 'Deploy .NET 8 version'
11+
type: boolean
12+
default: true
13+
deploy_net10:
14+
description: 'Deploy .NET 10 version'
15+
type: boolean
16+
default: true
817

918
env:
10-
AZURE_WEBAPP_NAME: PerfSimDotNet
11-
AZURE_WEBAPP_PACKAGE_PATH: './publish'
12-
DOTNET_VERSION: '10.0.x'
19+
# App Service names - update these to match your Azure resources
20+
AZURE_WEBAPP_NET8: PerfSimDotNet8
21+
AZURE_WEBAPP_NET10: PerfSimDotNet
1322

1423
permissions:
1524
id-token: write
1625
contents: read
1726

1827
jobs:
19-
build-and-deploy:
28+
build:
2029
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
include:
33+
- framework: net8.0
34+
dotnet-version: '8.0.x'
35+
artifact-name: publish-net8
36+
- framework: net10.0
37+
dotnet-version: '10.0.x'
38+
artifact-name: publish-net10
2139

2240
steps:
2341
- name: Checkout code
2442
uses: actions/checkout@v4
2543

26-
- name: Setup .NET
44+
- name: Setup .NET ${{ matrix.dotnet-version }}
2745
uses: actions/setup-dotnet@v4
2846
with:
29-
dotnet-version: ${{ env.DOTNET_VERSION }}
47+
dotnet-version: ${{ matrix.dotnet-version }}
3048

3149
- name: Restore dependencies
3250
run: dotnet restore src/PerfProblemSimulator/PerfProblemSimulator.csproj
3351

34-
- name: Build
35-
run: dotnet build src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --no-restore
52+
- name: Build (${{ matrix.framework }})
53+
run: dotnet build src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --framework ${{ matrix.framework }} --no-restore
3654

37-
- name: Publish
38-
run: dotnet publish src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --no-build --output ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
55+
- name: Publish (${{ matrix.framework }})
56+
run: dotnet publish src/PerfProblemSimulator/PerfProblemSimulator.csproj --configuration Release --framework ${{ matrix.framework }} --no-build --output ./publish
57+
58+
- name: Upload artifact
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: ${{ matrix.artifact-name }}
62+
path: ./publish
63+
64+
deploy-net8:
65+
needs: build
66+
runs-on: ubuntu-latest
67+
if: github.event_name == 'push' || github.event.inputs.deploy_net8 == 'true'
68+
69+
steps:
70+
- name: Download .NET 8 artifact
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: publish-net8
74+
path: ./publish-net8
75+
76+
- name: Login to Azure
77+
uses: azure/login@v2
78+
with:
79+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
80+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
81+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
82+
83+
- name: Deploy to Azure Web App (.NET 8)
84+
uses: azure/webapps-deploy@v3
85+
with:
86+
app-name: ${{ env.AZURE_WEBAPP_NET8 }}
87+
package: ./publish-net8
88+
89+
deploy-net10:
90+
needs: build
91+
runs-on: ubuntu-latest
92+
if: github.event_name == 'push' || github.event.inputs.deploy_net10 == 'true'
93+
94+
steps:
95+
- name: Download .NET 10 artifact
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: publish-net10
99+
path: ./publish-net10
39100

40101
- name: Login to Azure
41102
uses: azure/login@v2
@@ -44,8 +105,8 @@ jobs:
44105
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
45106
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
46107

47-
- name: Deploy to Azure Web App
108+
- name: Deploy to Azure Web App (.NET 10)
48109
uses: azure/webapps-deploy@v3
49110
with:
50-
app-name: ${{ env.AZURE_WEBAPP_NAME }}
51-
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
111+
app-name: ${{ env.AZURE_WEBAPP_NET10 }}
112+
package: ./publish-net10

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
-->
77

88
<PropertyGroup>
9-
<!-- Target .NET 10.0 for all projects -->
10-
<TargetFramework>net10.0</TargetFramework>
9+
<!-- Multi-target .NET 8.0 and .NET 10.0 for diagnostics compatibility -->
10+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
1111

1212
<!-- Enable nullable reference types for defensive programming (Constitution Principle IV) -->
1313
<Nullable>enable</Nullable>

src/PerfProblemSimulator/PerfProblemSimulator.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@
1717
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
1818
</PropertyGroup>
1919

20-
<ItemGroup>
20+
<!-- .NET 10 specific packages -->
21+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
2122
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
2223
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
2324
</ItemGroup>
2425

26+
<!-- .NET 8 specific packages -->
27+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
28+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
29+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
30+
</ItemGroup>
31+
2532
<!-- Generate build timestamp as assembly metadata -->
2633
<Target Name="SetBuildTimestamp" BeforeTargets="GetAssemblyAttributes">
2734
<PropertyGroup>

src/PerfProblemSimulator/Program.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
using PerfProblemSimulator.Models;
44
using PerfProblemSimulator.Services;
55

6+
#if NET8_0
7+
using OpenApiInfo = Microsoft.OpenApi.Models.OpenApiInfo;
8+
#else
9+
using OpenApiInfo = Microsoft.OpenApi.OpenApiInfo;
10+
#endif
11+
612
// =============================================================================
713
// Performance Problem Simulator - Application Entry Point
814
// =============================================================================
@@ -60,7 +66,7 @@
6066
builder.Services.AddEndpointsApiExplorer();
6167
builder.Services.AddSwaggerGen(options =>
6268
{
63-
options.SwaggerDoc("v1", new Microsoft.OpenApi.OpenApiInfo
69+
options.SwaggerDoc("v1", new OpenApiInfo
6470
{
6571
Title = "Performance Problem Simulator API",
6672
Version = "v1",

tests/PerfProblemSimulator.Tests/PerfProblemSimulator.Tests.csproj

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,25 @@
1010
<IsTestProject>true</IsTestProject>
1111
</PropertyGroup>
1212

13+
<!-- Common test packages -->
1314
<ItemGroup>
1415
<PackageReference Include="coverlet.collector" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0" />
1616
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
1717
<PackageReference Include="Moq" Version="4.20.72" />
1818
<PackageReference Include="xunit" Version="2.5.3" />
1919
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
2020
</ItemGroup>
2121

22+
<!-- .NET 10 specific test packages -->
23+
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
24+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.0" />
25+
</ItemGroup>
26+
27+
<!-- .NET 8 specific test packages -->
28+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
29+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
30+
</ItemGroup>
31+
2232
<ItemGroup>
2333
<Using Include="Xunit" />
2434
</ItemGroup>

0 commit comments

Comments
 (0)