Skip to content

Commit dd69d59

Browse files
authored
.NET 9 Upgrade (#5)
1 parent 4d35ce4 commit dd69d59

14 files changed

+47
-67
lines changed

.github/workflows/template-build-test-project.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ jobs:
3030
runs-on: ubuntu-latest
3131
strategy:
3232
matrix:
33-
dotnet-target-framework: ["net6.0", "net7.0", "net8.0"]
33+
dotnet-target-framework: ["net8.0", "net9.0"]
3434
include:
35-
- dotnet-install-framework: 6.0.x
36-
dotnet-target-framework: net6.0
37-
- dotnet-install-framework: 7.0.x
38-
dotnet-target-framework: net7.0
3935
- dotnet-install-framework: 8.0.x
4036
dotnet-target-framework: net8.0
37+
38+
- dotnet-install-framework: 9.0.x
39+
dotnet-target-framework: net9.0
4140
env:
4241
source-directory: ${{ inputs.source-directory }}
4342
source-project: ${{ inputs.source-project }}

.github/workflows/template-build-test-solution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
env:
21-
dotnet-install-framework: 8.0.x
21+
dotnet-install-framework: 9.0.x
2222

2323
defaults:
2424
run:

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup Label="Build Settings">
44
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6+
<LangVersion>preview</LangVersion>
67
</PropertyGroup>
78

89
<PropertyGroup Label="Compile Settings">

Directory.Packages.props

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,29 @@
66

77
<ItemGroup Label="Microsoft NuGet Packages (All Frameworks)">
88
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
9+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.6" />
10+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.6" />
911
</ItemGroup>
1012

11-
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net6.0'">
12-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.15" />
13-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
14-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.3" />
15-
</ItemGroup>
16-
17-
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net7.0'">
18-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.4" />
19-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
20-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
13+
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net8.0'">
14+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.17" />
2115
</ItemGroup>
2216

23-
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net8.0'">
24-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.2" />
25-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
26-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
17+
<ItemGroup Label="Microsoft NuGet Packages (Source)" Condition="'$(TargetFramework)' == 'net9.0'">
18+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.6" />
2719
</ItemGroup>
2820

2921
<ItemGroup Label="Microsoft NuGet Packages (Test)">
30-
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
31-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
32-
<PackageVersion Include="xunit" Version="2.5.0" />
33-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
22+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
23+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
24+
<PackageVersion Include="xunit" Version="2.9.3" />
25+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
3426
</ItemGroup>
3527

3628
<ItemGroup Label="External Testing Packages">
37-
<PackageVersion Include="Bogus" Version="34.0.2" />
38-
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
39-
<PackageVersion Include="Moq" Version="4.18.3" />
29+
<PackageVersion Include="Bogus" Version="35.6.3" />
30+
<PackageVersion Include="FluentAssertions" Version="[7.0.0]" />
31+
<PackageVersion Include="Moq" Version="[4.18.4]" />
4032
<PackageVersion Include="BlazorFocused.Testing.Logging" Version="1.0.0" />
4133
</ItemGroup>
4234

samples/Directory.Packages.props

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
</PropertyGroup>
66

77
<ItemGroup Label="Microsoft NuGet Packages (Source)">
8-
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-rc.1.23421.29" />
9-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
8+
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
109
</ItemGroup>
1110

1211
<ItemGroup Label="Microsoft NuGet Packages (Test)">
13-
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
14-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.1.23421.29" />
15-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
16-
<PackageVersion Include="xunit" Version="2.5.0" />
17-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
12+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
13+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.6" />
14+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
15+
<PackageVersion Include="xunit" Version="2.9.3" />
16+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.1" />
1817
</ItemGroup>
1918

2019
<ItemGroup Label="External Testing Packages">
21-
<PackageVersion Include="Bogus" Version="34.0.2" />
22-
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
23-
<PackageVersion Include="Moq" Version="4.18.3" />
20+
<PackageVersion Include="Bogus" Version="35.6.3" />
21+
<PackageVersion Include="FluentAssertions" Version="[7.0.0]" />
22+
<PackageVersion Include="Moq" Version="[4.18.4]" />
2423
</ItemGroup>
2524

2625
</Project>

samples/MiddlewareSample/MiddlewareSample.Api.Test/MiddlewareSample.Api.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<IsTestProject>true</IsTestProject>
77
</PropertyGroup>

samples/MiddlewareSample/MiddlewareSample.Api/MiddlewareSample.Api.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
10-
<PackageReference Include="Swashbuckle.AspNetCore" />
1110
</ItemGroup>
1211

1312
<ItemGroup>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@baseAddress = https://localhost:7288
2+
3+
GET {{baseAddress}}/ThrowRandomException
4+
5+
###
6+
7+
GET {{baseAddress}}/ThrowCustomClientException?statusCode=400&message=Test%20Exception%20Throw
8+

samples/MiddlewareSample/MiddlewareSample.Api/Program.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
1212

1313
builder.Services.AddEndpointsApiExplorer();
14-
builder.Services.AddSwaggerGen();
14+
builder.Services.AddOpenApi();
1515

1616
// Register custom exceptions and status codes
1717
builder.Services
@@ -20,15 +20,14 @@
2020
{
2121
options.CorrelationKey = "X-TestCorrelation-Id";
2222
options.CorrelationKey = CORRELATION_HEADER_KEY;
23-
options.ConfigureCorrelationValue = (httpContext) => { return httpContext.TraceIdentifier; };
23+
options.ConfigureCorrelationValue = (httpContext) => httpContext.TraceIdentifier;
2424
}) // Use this extension for default correlation key/value
2525
.AddException<RandomException>(HttpStatusCode.FailedDependency);
2626

2727
WebApplication app = builder.Build();
2828

29-
app.UseSwagger();
30-
app.UseSwaggerUI();
3129
app.UseHttpsRedirection();
30+
app.MapOpenApi();
3231

3332
// Register Exceptions API Middleware
3433
app.UseExceptionsMiddleware();

samples/MiddlewareSample/MiddlewareSample.Api/Properties/launchSettings.json

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
{
22
"$schema": "https://json.schemastore.org/launchsettings.json",
33
"profiles": {
4-
"Sample API - Http": {
5-
"commandName": "Project",
6-
"dotnetRunMessages": true,
7-
"launchBrowser": true,
8-
"launchUrl": "swagger",
9-
"applicationUrl": "http://localhost:5176",
10-
"environmentVariables": {
11-
"ASPNETCORE_ENVIRONMENT": "Development"
12-
}
13-
},
144
"Sample API - Https": {
155
"commandName": "Project",
166
"dotnetRunMessages": true,
177
"launchBrowser": true,
18-
"launchUrl": "swagger",
8+
"launchUrl": "openapi/v1.json",
199
"applicationUrl": "https://localhost:7288;http://localhost:5101",
2010
"environmentVariables": {
2111
"ASPNETCORE_ENVIRONMENT": "Development"

0 commit comments

Comments
 (0)