Skip to content

Commit b506b99

Browse files
committed
Add .NET 10 to the list of TFMs
- Update GitHub Actions configuration - Update tests due to .NET 10 breaking changes
1 parent efdf64f commit b506b99

5 files changed

Lines changed: 31 additions & 3 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
7.x
3737
8.x
3838
9.x
39+
10.x
3940
- name: Restore
4041
run: dotnet restore
4142
- name: Build
@@ -51,7 +52,7 @@ jobs:
5152
- name: Setup .NET Core
5253
uses: actions/setup-dotnet@v5
5354
with:
54-
dotnet-version: 9.x
55+
dotnet-version: 10.x
5556
- name: Restore tools
5657
run: dotnet tool restore
5758
- name: Build solution

.github/workflows/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
7.x
3939
8.x
4040
9.x
41+
10.x
4142
- name: Restore
4243
run: dotnet restore
4344
- name: Build
@@ -59,6 +60,7 @@ jobs:
5960
7.x
6061
8.x
6162
9.x
63+
10.x
6264
- name: Create Release NuGet package
6365
run: |
6466
arrTag=(${GITHUB_REF//\// })

src/Giraffe/Giraffe.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<NeutralLanguage>en-GB</NeutralLanguage>
1010

1111
<!-- Build settings -->
12-
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
12+
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
1313
<DebugType>portable</DebugType>
1414
<OutputType>Library</OutputType>
1515
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

tests/Giraffe.Tests/Giraffe.Tests.fsproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
3+
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
44
<AssemblyName>Giraffe.Tests</AssemblyName>
55
</PropertyGroup>
66

@@ -46,6 +46,10 @@
4646
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.*" />
4747
</ItemGroup>
4848

49+
<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0'">
50+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.*" />
51+
</ItemGroup>
52+
4953
<ItemGroup>
5054
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
5155
<PackageReference Include="xunit" Version="2.9.*" />

tests/Giraffe.Tests/Helpers.fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ open Microsoft.AspNetCore.Hosting
1414
open Microsoft.AspNetCore.TestHost
1515
open Microsoft.AspNetCore.Builder
1616
open Microsoft.Extensions.DependencyInjection
17+
open Microsoft.Extensions.Hosting
1718
open Xunit
1819
open NSubstitute
1920
open Giraffe
@@ -94,10 +95,22 @@ let createHost
9495
(configureServices: IServiceCollection -> unit)
9596
(args: 'Tuple)
9697
=
98+
#if NET10_0_OR_GREATER
99+
HostBuilder()
100+
.ConfigureWebHost(fun webHostBuilder ->
101+
webHostBuilder
102+
.UseTestServer()
103+
.UseContentRoot(Path.GetFullPath("TestFiles"))
104+
.Configure(Action<IApplicationBuilder>(configureApp args))
105+
.ConfigureServices(Action<IServiceCollection> configureServices)
106+
|> ignore
107+
)
108+
#else
97109
(WebHostBuilder())
98110
.UseContentRoot(Path.GetFullPath("TestFiles"))
99111
.Configure(Action<IApplicationBuilder>(configureApp args))
100112
.ConfigureServices(Action<IServiceCollection> configureServices)
113+
#endif
101114

102115
let mockJson (ctx: HttpContext) =
103116

@@ -131,7 +144,15 @@ let createRequest (method: HttpMethod) (path: string) =
131144

132145
let makeRequest configureApp configureServices args (request: HttpRequestMessage) =
133146
task {
147+
#if NET10_0_OR_GREATER
148+
// https://github.com/aspnet/Announcements/issues/526
149+
let host = createHost configureApp configureServices args |> _.Build()
150+
151+
let! _ = host.StartAsync()
152+
use server = host.GetTestServer()
153+
#else
134154
use server = new TestServer(createHost configureApp configureServices args)
155+
#endif
135156
use client = server.CreateClient()
136157
let! response = request |> client.SendAsync
137158
return response

0 commit comments

Comments
 (0)