ASP.NET Core 3.0 から3.1 への移行Migrate from ASP.NET Core 3.0 to 3.1
作成者: Scott AddieBy Scott Addie
この記事では、既存の ASP.NET Core 3.0 プロジェクトを ASP.NET Core 3.1 に更新する方法について説明します。This article explains how to update an existing ASP.NET Core 3.0 project to ASP.NET Core 3.1.
必須コンポーネントPrerequisites
- Visual StudioVisual Studio
- Visual Studio CodeVisual Studio Code
- Visual Studio for MacVisual Studio for Mac
ASP.NET および Web 開発 ワークロードを含む Visual Studio 2019 16.4 以降Visual Studio 2019 16.4 or later with the ASP.NET and web development workload
global.json での .NET Core SDK バージョンの更新Update .NET Core SDK version in global.json
ファイル のglobal.js に依存して特定の .NET Core SDK バージョンを対象とする場合は、プロパティを、 version
インストールされている 3.1 SDK バージョンに更新します。If you rely upon a global.json file to target a specific .NET Core SDK version, update the version
property to the 3.1 SDK version that's installed. 次に例を示します。For example:
{
"sdk": {
- "version": "3.0.101"
+ "version": "3.1.101"
}
}
ターゲットフレームワークを更新するUpdate the target framework
プロジェクトファイルで、 ターゲットフレームワークモニカー (TFM) を次のように更新し netcoreapp3.1
ます。In the project file, update the Target Framework Moniker (TFM) to netcoreapp3.1
:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
- <TargetFramework>netcoreapp3.0</TargetFramework>
+ <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>
パッケージ参照の更新Update package references
プロジェクトファイルで、各 Microsoft.AspNetCore.*
パッケージ参照の Version
属性を3.1.0 以降に更新します。In the project file, update each Microsoft.AspNetCore.*
package reference's Version
attribute to 3.1.0 or later. 次に例を示します。For example:
<ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
- <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.0.0" Condition="'$(Configuration)' == 'Debug'" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.1" />
+ <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.1" Condition="'$(Configuration)' == 'Debug'" />
</ItemGroup>
Docker イメージの更新Update Docker images
Docker を使用するアプリでは、ASP.NET Core 3.1 を含む基本イメージを使用します。For apps using Docker, use a base image that includes ASP.NET Core 3.1. 次に例を示します。For example:
docker pull mcr.microsoft.com/dotnet/core/aspnet:3.1
SameSite の変更に対処する cookieReact to SameSite cookie changes
SameSite
HTTP s の属性の実装が cookie ASP.NET Core 3.0 と3.1 の間で変更されました。The SameSite
attribute implementations for HTTP cookies changed between ASP.NET Core 3.0 and 3.1. アクションを実行するには、次のリソースを参照してください。For actions to be taken, see the following resources:
- cookieASP.NET Core での SameSite s の使用
- aspnet/アナウンス # 390aspnet/Announcements#390
- cookieASP.NET と ASP.NET Core の今後の SameSite の変更点Upcoming SameSite cookie changes in ASP.NET and ASP.NET Core
重大な変更の確認Review breaking changes
.NET Core、ASP.NET Core、Entity Framework Core および バージョン3.0 から3.1 への移行の互換性に影響する変更点について、3.0 から3.1 への重大な変更を確認します。Review 3.0-to-3.1 breaking changes across .NET Core, ASP.NET Core, and Entity Framework Core at Breaking changes for migration from version 3.0 to 3.1.
オプションの変更Optional changes
次の変更は省略可能です。The following changes are optional.
コンポーネントタグヘルパーを使用するUse the Component Tag Helper
ASP.NET Core 3.1 では、タグヘルパーが導入さ Component
れています。ASP.NET Core 3.1 introduces a Component
Tag Helper. タグヘルパーは、 RenderComponentAsync<TComponent>
プロジェクトの HTML ヘルパーメソッドを置き換えることができ Blazor ます。The Tag Helper can replace the RenderComponentAsync<TComponent>
HTML helper method in a Blazor project. 次に例を示します。For example:
- @(await Html.RenderComponentAsync<Counter>(RenderMode.ServerPrerendered, new { IncrementAmount = 10 }))
+ <component type="typeof(Counter)" render-mode="ServerPrerendered" param-IncrementAmount="10" />
詳細については、「ASP.NET Core Razor コンポーネントのプリレンダリングと統合を行う」を参照してください。For more information, see ASP.NET Core Razor コンポーネントのプリレンダリングと統合を行う.