88 lines
2.6 KiB
Markdown
88 lines
2.6 KiB
Markdown
|
---
|
||
|
title: Migrate from ASP.NET Core 3.1 to 5.0
|
||
|
author: scottaddie
|
||
|
description: Learn how to migrate an ASP.NET Core 3.1 project to ASP.NET Core 5.0.
|
||
|
ms.author: scaddie
|
||
|
ms.custom: mvc
|
||
|
ms.date: 03/23/2020
|
||
|
uid: migration/31-to-50
|
||
|
---
|
||
|
# Migrate from ASP.NET Core 3.1 to 5.0
|
||
|
|
||
|
By [Scott Addie](https://github.com/scottaddie)
|
||
|
|
||
|
This article explains how to update an existing ASP.NET Core 3.1 project to ASP.NET Core 5.0.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> ASP.NET Core 5.0 is currently in preview.
|
||
|
|
||
|
## Prerequisites
|
||
|
|
||
|
# [Visual Studio](#tab/visual-studio)
|
||
|
|
||
|
[!INCLUDE[](~/includes/net-core-prereqs-vs-5.0.md)]
|
||
|
|
||
|
# [Visual Studio Code](#tab/visual-studio-code)
|
||
|
|
||
|
[!INCLUDE[](~/includes/net-core-prereqs-vsc-5.0.md)]
|
||
|
|
||
|
# [Visual Studio for Mac](#tab/visual-studio-mac)
|
||
|
|
||
|
[!INCLUDE[](~/includes/net-core-prereqs-mac-5.0.md)]
|
||
|
|
||
|
---
|
||
|
|
||
|
## Update .NET Core SDK version in global.json
|
||
|
|
||
|
If you rely upon a [global.json](/dotnet/core/tools/global-json) file to target a specific .NET Core SDK version, update the `version` property to the .NET 5.0 SDK version that's installed. For example:
|
||
|
|
||
|
```diff
|
||
|
{
|
||
|
"sdk": {
|
||
|
- "version": "3.1.200"
|
||
|
+ "version": "5.0.100-preview.1.20155.7"
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## Update the target framework
|
||
|
|
||
|
In the project file, update the [Target Framework Moniker (TFM)](/dotnet/standard/frameworks) to `netcoreapp5.0`:
|
||
|
|
||
|
```diff
|
||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||
|
|
||
|
<PropertyGroup>
|
||
|
- <TargetFramework>netcoreapp3.1</TargetFramework>
|
||
|
+ <TargetFramework>netcoreapp5.0</TargetFramework>
|
||
|
</PropertyGroup>
|
||
|
|
||
|
</Project>
|
||
|
```
|
||
|
|
||
|
## Update package references
|
||
|
|
||
|
In the project file, update each `Microsoft.AspNetCore.*` and `Microsoft.Extensions.*` package reference's `Version` attribute to 5.0.0 or later. For example:
|
||
|
|
||
|
```diff
|
||
|
<ItemGroup>
|
||
|
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
|
||
|
+ <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="3.1.2" />
|
||
|
- <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0-preview.1.20124.5" />
|
||
|
- <PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="5.0.0-preview.1.20120.4" />
|
||
|
</ItemGroup>
|
||
|
```
|
||
|
|
||
|
## Update Docker images
|
||
|
|
||
|
For apps using Docker, use a base image that includes ASP.NET Core 5.0. For example:
|
||
|
|
||
|
```bash
|
||
|
docker pull mcr.microsoft.com/dotnet/core/aspnet:5.0
|
||
|
```
|
||
|
|
||
|
<!-- uncomment after the breaking changes have been published -->
|
||
|
<!-- ## Review breaking changes
|
||
|
|
||
|
Review 3.1-to-5.0 breaking changes across .NET Core, ASP.NET Core, and Entity Framework Core at [Breaking changes for migration from version 3.1 to 5.0](/dotnet/core/compatibility/3.1-5.0). -->
|