How do you upgrade an ASP.NET Core 8 web app to .NET 10, and what has to change besides the TargetFramework?
answer
- SDK first, then the project file
- TargetFramework net10.0
- Microsoft.AspNetCore.* packages to 10.0.x
- the shared framework follows the TFM
- dotnet package list --outdated
basics
~20 sInstall the .NET 10 SDK, set TargetFramework to net10.0, move every Microsoft.AspNetCore., Microsoft.EntityFrameworkCore. and Microsoft.Extensions.* package to 10.0.x, update third-party packages, then fix the new warnings and test against the 9 and 10 breaking changes.
solid answer
~40 sFirst get a .NET 10 SDK (10.0.100 or later) onto developer machines and CI, updating a `global.json` pin if there is one. Then change `TargetFramework` from `net8.0` to `net10.0`; the Web SDK's implicit `FrameworkReference` to `Microsoft.AspNetCore.App` follows the TFM, so the shared framework itself has no version to edit. What does need editing is every `PackageReference` that ships alongside it: `Microsoft.AspNetCore.Authentication.JwtBearer`, `Microsoft.AspNetCore.OpenApi`, `Microsoft.EntityFrameworkCore.*` with its provider, explicitly referenced `Microsoft.Extensions.*` packages and `System.Net.Http.Json`, all to 10.0.x, plus third-party packages to versions that support .NET 10; `dotnet package list --outdated` finds them. Build, treat the new obsolescence warnings (the `ASPDEPR` ids) as work items, run the tests with the .NET 9 and .NET 10 breaking-change lists in hand, and finally move servers or container base images to the .NET 10 runtime.
code
xml · 16 lines<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.0" />
</ItemGroup>
</Project>go deeper
Know that an upgrade means a new SDK, a new TargetFramework and new package versions, not just one line.
Explain why Microsoft.AspNetCore.App follows the TFM while JwtBearer, OpenApi and EF Core packages need explicit bumps, and how to find stale ones.
Run the upgrade as SDK, TFM, packages, warnings, tests, runtime, and know that skipping .NET 9 means reading two breaking-change lists.
Standardise the mechanics across repositories, with central TFM and package versions, so each yearly or two-yearly upgrade is a small, repeatable change.
## What actually carries the version An ASP.NET Core app's version lives in more places than the `TargetFramework`, and an upgrade touches each of them. | Where | What it is | What changes for 8 to 10 | |---|---|---| | Developer machines and CI agents | the .NET SDK | install a 10.0.1xx-or-later SDK; update `global.json` if it pins one | | `.csproj` or `Directory.Build.props` | `TargetFramework` | `net8.0` becomes `net10.0` | | Implicit `FrameworkReference` | `Microsoft.AspNetCore.App`, the shared framework | nothing to edit; it follows the TFM | | `PackageReference` items | packages built with ASP.NET Core, EF Core and the runtime but shipped on NuGet | each one to 10.0.x | | Third-party `PackageReference` items | Swashbuckle, Npgsql, Serilog and the like | versions that support .NET 10 | | Servers, containers | the runtime that executes the app | the .NET 10 ASP.NET Core runtime or base image | The shared framework is the subtle row. `Microsoft.NET.Sdk.Web` adds `<FrameworkReference Include="Microsoft.AspNetCore.App" />` for you, and its version comes from the TFM, which is why a web project has no `Microsoft.AspNetCore.App` package to bump. Packages that are not in the shared framework, such as `Microsoft.AspNetCore.Authentication.JwtBearer` or `Microsoft.AspNetCore.OpenApi`, carry their own version numbers and stay on 8.0.x until you change them. ## Step by step 1. **SDK.** Install the .NET 10 SDK on every machine that builds, including CI images. A `global.json` pinned to an 8.0 SDK blocks a `net10.0` build until you update it. 2. **TFM.** Change `TargetFramework` to `net10.0`, ideally once in `Directory.Build.props` if the solution centralises it. 3. **Microsoft packages.** Move `Microsoft.AspNetCore.*`, `Microsoft.EntityFrameworkCore.*`, explicitly referenced `Microsoft.Extensions.*` and `System.Net.Http.Json` to 10.0.x together; keep EF Core, its provider and the `dotnet-ef` tool on the same major. 4. **Third-party packages.** List what is stale with `dotnet package list --outdated` and move each to a release that supports .NET 10, reading its own release notes for majors. 5. **Build.** New obsolescence warnings appear with `ASPDEPR` ids, such as `ASPDEPR002` for `WithOpenApi()`; fix or schedule each. 6. **Test.** Behavioural breaking changes do not warn, so run the integration tests and read the .NET 9 and .NET 10 breaking-change pages; skipping .NET 9 means you take both lists at once. 7. **Deploy.** Install the .NET 10 runtime on framework-dependent servers or change the container base image to the 10.0 tag, and ship. ## Finding stale packages `dotnet package list --outdated` reports, per project and target framework, each package with its requested, resolved and latest version; `--include-transitive` extends the report to indirect dependencies. It is the quickest way to spot a forgotten `Microsoft.AspNetCore.*` reference left on 8.0.x after the TFM moved. The `--deprecated` and `--vulnerable` options of the same command flag packages their authors have deprecated or that have known advisories, which an upgrade is a good moment to clear. ## Things that do not need a version bump - **Program.cs.** A `WebApplication`-based Program.cs from .NET 8 compiles on .NET 10; you change it only where warnings or tests say so. - **Packages built for net8.0.** A library that only ships `net8.0` assets still installs and runs in a `net10.0` project, because a newer TFM is compatible with older ones. Upgrade it for fixes, not for compatibility. - **C# version.** The language version follows the TFM, so `net10.0` brings C# 14 without a `LangVersion` setting. ## A hotel reservations API, concretely For a reservations API built on .NET 8 with JWT bearer auth, the built-in OpenAPI document and EF Core on SQL Server, the edit is the TFM plus four package versions (JwtBearer, OpenApi, the EF Core SQL Server provider and EF Core Design), then a build that surfaces any `WithOpenApi()` call as `ASPDEPR002`, then tests that check status codes and logs where .NET 10 changed behaviour. That project-file edit is the whole of the mechanical part; everything after it is verification.
- Does Program.cs have to change when moving a WebApplication app from 8 to 10?Usually not: it compiles as is. You change what the build flags, such as WithOpenApi() under ASPDEPR002, and what tests reveal from behavioural changes such as cookie authentication returning 401 or 403 to API endpoints. An app still built on WebHost.CreateDefaultBuilder gets ASPDEPR008 and is the one that needs real rework.
- What about EF Core and its database provider?Move Microsoft.EntityFrameworkCore.*, the provider and the dotnet-ef tool to the same major together, for example EF Core 10 with an EF Core 10 build of the provider. EF Core publishes its own breaking-change list per release, which an 8-to-10 jump also has to read for 9 and 10.
- Changing TargetFramework to net10.0 is the whole upgrade.
- Microsoft.AspNetCore.App needs a PackageReference version bump.
- A package that only ships net8.0 assets cannot be used from a net10.0 project.
- Framework-dependent servers need nothing new when the app retargets to net10.0.
- Installing the .NET 10 SDK on its own moves the app to .NET 10.
Assumes a move from .NET 8 to .NET 10 with ASP.NET Core 10.0.x packages and a 10.0 SDK; the jump crosses .NET 9, so the 9.0 breaking changes apply as well.