WebApplicationFactory integration tests fail on .NET SDK 10.0.302 with FileNotFoundException for ASP.NET Core hosting assemblies
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
### Describe the bug
Integration tests using WebApplicationFactory fail to load ASP.NET Core shared framework assemblies on .NET SDK 10.0.302, but pass without issue on .NET SDK 10.0.301. Both SDK versions ship with the same runtime (10.0.10).
The failure occurs specifically when using testhost with ASP.NET Core framework references, suggesting a regression in SDK 10.0.302's build output or runtime configuration generation.
### Steps to reproduce
Steps to Reproduce:
Create an ASP.NET Core integration test project that uses:
Microsoft.NET.Sdk.Web SDK
WebApplicationFactory for hosting
xUnit test runner
ASP.NET Core TestHost
Build and run tests with SDK 10.0.302:
```
dotnet new web -n MyApp
dotnet new xunit -n MyApp.IntegrationTests
cd MyApp.IntegrationTests
dotnet add reference ../MyApp/MyApp.csproj
dotnet add package Microsoft.AspNetCore.Mvc.Testing
dotnet test
```
Tests fail during testhost initialization
Downgrade to SDK 10.0.301 and re-run the same tests — they pass
### Expected behavior
Integration tests using WebApplicationFactory should run successfully on SDK 10.0.302
ASP.NET Core shared framework assemblies should be resolved correctly by testhost apphost
Behavior should be consistent across SDK patch versions within the same major.minor release
### Actual behavior
Tests fail during startup with:
```
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Server.Abstractions, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Hosting.Abstractions, Version=10.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
```
The runtimeconfig.json generated by the build correctly references Microsoft.AspNetCore.App framework, but testhost fails to resolve it at runtime.
### Is this a regression?
Yes. This is a regression introduced between SDK 10.0.301 (works) and 10.0.302 (fails). The code, runtime version, and ASP.NET Core packages are unchanged.
Environment:
- .NET SDK: 10.0.302
- Runtime: 10.0.10 (shipped with SDK 10.0.302)
- OS: Linux (tested on bash shell runner environment)
- Test Framework: xUnit
- Test Host: Microsoft.AspNetCore.TestHost 10.0.7
- Hosting: WebApplicationFactory
### Are there any workarounds?
Pin SDK version to 10.0.301 in CI/CD pipelines.
### dotnet --info output
```console
=== SDK 10.0.302 ===
.NET SDK:
Version: 10.0.302
Commit: [commit hash]
Workload version: [version]
Runtime Environment:
OS Name: linux
OS Version: [kernel version]
OS Platform: Linux
RID: linux-x64
Base Path: /path/to/dotnet/sdk/10.0.302/
Host:
Version: 10.0.10
Architecture: x64
Commit: [commit hash]
.NET workloads installed:
No workloads are installed.
Host environment:
dotnet root [/tmp/dotnet or similar]:
PATH : [dotnet path]
DOTNET_ROOT(x64) : [path]
DOTNET_ROOT(x86) : [not set]
DOTNET_MULTILEVEL_LOOKUP : 0
=== SDK 10.0.301 (for comparison) ===
[Same format with 10.0.301 version]
```
### IDE version
_No response_
### Other details
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.