dotnet / dotnet/aspnetcore

Compile Error After Upgrading - SDK 8.0.300, "AspNetCore" cannot be found

Open
#56,220 5 comments 1 reaction 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Description
After upgrading from SDK 8.0.204 to SDK 8.0.300, "AspNetCore" cannot be found within "Microsoft.AspNetCore.Mvc" using statement. Compile fails, and attempts to extend/use ControllerBase fail because ControllerBase cannot be found due to this. Reverting to SDK 8.0.204 solves this.

Reversion process:
choco uninstall dotnet-sdk
choco install dotnet-sdk --version=8.0.204

### To Reproduce
Can't currently provide a full repo or project to repro due to lack of time (sincere apologies), but the following file is a version of the file I'm seeing this in, with sensitive info renamed or removed.

```csharp
namespace TestSupport;
using Autofac;
using Infrastructure.Logging.Modules;
using Microsoft.AspNetCore.Mvc;

public abstract class WebApiControllerScenario : TransactionScopedScenario
where TDerived : WebApiControllerScenario
where TController : ControllerBase {

protected WebApiControllerScenario() {
Controller = this.Resolve();
}

protected TController Controller { get; }

protected override void RegisterModules(ContainerBuilder builder) {
builder.RegisterModule();
}

protected override void RegisterScenarioTypes(ContainerBuilder builder) {
builder.RegisterType().AsSelf();
}
}
```

### Exceptions (if any)
- error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
- The type or namespace name 'ControllerBase' could not be found (are you missing a using directive or an assembly reference?)
- The type 'TController' cannot be used as type parameter 'TController' in the generic type or method 'WebApiControllerScenario'. There is no boxing conversion or type parameter conversion from 'TController' to 'ControllerBase'

### Further technical details
- Include the output of `dotnet --info`
dotnet --info output:
```
.NET SDK:
Version: 8.0.300
Commit: 326f6e68b2
Workload version: 8.0.300-manifests.4e5ea2d8
MSBuild version: 17.10.4+10fbfbf2e

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.300\

.NET workloads installed:
[aspire]
Installation Source: VS 17.10.34916.146
Manifest Version: 8.0.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.0.0\WorkloadManifest.json
Install Type: Msi

[maui-windows]
Installation Source: VS 17.10.34916.146
Manifest Version: 8.0.21/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.21\WorkloadManifest.json
Install Type: Msi

[android]
Installation Source: VS 17.10.34916.146
Manifest Version: 34.0.95/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.95\WorkloadManifest.json
Install Type: Msi

[maccatalyst]
Installation Source: VS 17.10.34916.146
Manifest Version: 17.2.8053/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8053\WorkloadManifest.json
Install Type: Msi

[wasm-tools-net6]
Installation Source: VS 17.10.34916.146
Manifest Version: 8.0.5/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net6\8.0.5\WorkloadManifest.json
Install Type: Msi

[wasm-tools-net7]
Installation Source: VS 17.10.34916.146
Manifest Version: 8.0.5/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.net7\8.0.5\WorkloadManifest.json
Install Type: Msi

[ios]
Installation Source: VS 17.10.34916.146
Manifest Version: 17.2.8053/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8053\WorkloadManifest.json
Install Type: Msi

[wasm-tools]
Installation Source: VS 17.10.34916.146
Manifest Version: 8.0.5/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.5\WorkloadManifest.json
Install Type: Msi

Host:
Version: 8.0.5
Architecture: x64
Commit: 087e15321b

.NET SDKs installed:
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.422 [C:\Program Files\dotnet\sdk]
7.0.407 [C:\Program Files\dotnet\sdk]
8.0.105 [C:\Program Files\dotnet\sdk]
8.0.205 [C:\Program Files\dotnet\sdk]
8.0.300 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download
```
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
IDE: Visual Studio 2022, Rider 2024.1.2, Nuke, and dotnet build all produce this.

Workaround: Revert to sdk 8.0.204

Contributor guide

Open the contributing guide

Research direction

Start by comparing the reported build with SDK 8.0.204 and 8.0.300 using the supplied C# example and `dotnet --info` output. Check the project’s ASP.NET Core references and run `dotnet build` under both SDK versions; done means identifying a reproducible SDK-related cause and confirming that `AspNetCore` and `ControllerBase` resolve without reverting.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.