migrate-dotnet9-to-dotnet10
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese.NET 9 → .NET 10 Migration
.NET 9 迁移至 .NET 10
Migrate a .NET 9 project or solution to .NET 10, systematically resolving all breaking changes. The outcome is a project targeting that builds cleanly, passes tests, and accounts for every behavioral, source-incompatible, and binary-incompatible change introduced in the .NET 10 release.
net10.0将.NET 9项目或解决方案迁移至.NET 10,系统地解决所有重大变更。最终目标是得到一个以为目标框架的项目,能够干净构建、通过测试,并适配.NET 10版本中引入的所有行为、源代码不兼容和二进制不兼容变更。
net10.0When to Use
适用场景
- Upgrading from
TargetFrameworktonet9.0net10.0 - Resolving build errors or new warnings after updating the .NET 10 SDK
- Adapting to behavioral changes in .NET 10 runtime, ASP.NET Core 10, or EF Core 10
- Updating CI/CD pipelines, Dockerfiles, or deployment scripts for .NET 10
- Migrating from the community package to the built-in
System.Linq.AsyncSystem.Linq.AsyncEnumerable
- 将从
TargetFramework升级至net9.0net10.0 - 更新.NET 10 SDK后解决构建错误或新警告
- 适配.NET 10运行时、ASP.NET Core 10或EF Core 10中的行为变更
- 为.NET 10更新CI/CD流水线、Dockerfile或部署脚本
- 从社区包迁移至内置的
System.Linq.AsyncSystem.Linq.AsyncEnumerable
When Not to Use
不适用场景
- The project already targets and builds cleanly — migration is done
net10.0 - Upgrading from .NET 8 or earlier — use the skill first to reach
migrate-dotnet8-to-dotnet9, then return to this skill for thenet9.0→net9.0migrationnet10.0 - Migrating from .NET Framework — that is a separate, larger effort
- Greenfield projects that start on .NET 10 (no migration needed)
- 项目已以为目标框架且能干净构建——迁移已完成
net10.0 - 从.NET 8或更早版本升级——请先使用工具升级至
migrate-dotnet8-to-dotnet9,再使用本工具进行net9.0→net9.0的迁移net10.0 - 从.NET Framework迁移——这是独立的大型迁移工作
- 全新.NET 10项目(无需迁移)
Inputs
输入项
| Input | Required | Description |
|---|---|---|
| Project or solution path | Yes | The |
| Build command | No | How to build (e.g., |
| Test command | No | How to run tests (e.g., |
| Project type hints | No | Whether the project uses ASP.NET Core, EF Core, WinForms, WPF, containers, etc. Auto-detect from PackageReferences and SDK attributes if not provided |
| 输入项 | 是否必填 | 描述 |
|---|---|---|
| 项目或解决方案路径 | 是 | 要迁移的 |
| 构建命令 | 否 | 构建方式(如 |
| 测试命令 | 否 | 测试运行方式(如 |
| 项目类型提示 | 否 | 项目是否使用ASP.NET Core、EF Core、WinForms、WPF、容器等。未提供时从PackageReferences和SDK属性自动检测 |
Workflow
工作流程
Answer directly from the loaded reference documents. Do not search the filesystem or fetch web pages for breaking change information — the references contain the authoritative details. Focus on identifying which breaking changes apply and providing concrete fixes. Exception: If you suspect a security vulnerability (CVE) may apply to the project's dependencies, check for published security advisories — the reference documents may not cover post-publication CVEs.Commit strategy: Commit at each logical boundary — after updating the TFM (Step 2), after resolving build errors (Step 3), after addressing behavioral changes (Step 4), and after updating infrastructure (Step 5). This keeps each commit focused and reviewable.
直接从加载的参考文档中获取答案。不要搜索文件系统或网页获取重大变更信息——参考文档包含权威细节。重点识别适用的重大变更并提供具体修复方案。例外情况:如果怀疑项目依赖项存在安全漏洞(CVE),请检查已发布的安全公告——参考文档可能未涵盖发布后的CVE。提交策略:在每个逻辑阶段提交代码——更新TFM后(步骤2)、解决构建错误后(步骤3)、处理行为变更后(步骤4)、更新基础设施后(步骤5)。这样每个提交都聚焦明确,便于评审。
Step 1: Assess the project
步骤1:评估项目
- Identify how the project is built and tested. Look for build scripts, /
.slnfiles, or individual.slnxfiles..csproj - Run to confirm the .NET 10 SDK is installed. If it is not, stop and inform the user.
dotnet --version - Determine which technology areas the project uses by examining:
- SDK attribute: → ASP.NET Core;
Microsoft.NET.Sdk.WebwithMicrosoft.NET.Sdk.WindowsDesktopor<UseWPF>→ WPF/WinForms<UseWindowsForms> - PackageReferences: → EF Core;
Microsoft.EntityFrameworkCore.*→ Sqlite;Microsoft.Data.Sqlite→ Generic Host / BackgroundServiceMicrosoft.Extensions.Hosting - Dockerfile presence → Container changes relevant
- P/Invoke or native interop usage → Interop changes relevant
- package reference → AsyncEnumerable migration needed
System.Linq.Async - usage with polymorphism → Serialization changes relevant
System.Text.Json
- SDK attribute:
- Record which reference documents are relevant (see the reference loading table in Step 3).
- Do a clean build (or delete
dotnet build --no-incremental/bin) on the currentobjtarget to establish a clean baseline. Record any pre-existing warnings.net9.0
- 确定项目的构建和测试方式。查找构建脚本、/
.sln文件或单个.slnx文件。.csproj - 运行确认已安装.NET 10 SDK。若未安装,停止操作并告知用户。
dotnet --version - 通过检查以下内容确定项目使用的技术领域:
- SDK属性:→ ASP.NET Core;
Microsoft.NET.Sdk.Web搭配Microsoft.NET.Sdk.WindowsDesktop或<UseWPF>→ WPF/WinForms<UseWindowsForms> - PackageReferences:→ EF Core;
Microsoft.EntityFrameworkCore.*→ Sqlite;Microsoft.Data.Sqlite→ 通用宿主/BackgroundServiceMicrosoft.Extensions.Hosting - Dockerfile存在性 → 需关注容器相关变更
- P/Invoke或本地互操作使用情况 → 需关注互操作变更
- 包引用 → 需要迁移至AsyncEnumerable
System.Linq.Async - 使用的多态场景 → 需关注序列化变更
System.Text.Json
- SDK属性:
- 记录相关的参考文档(见步骤3中的参考文档加载表)。
- 对当前目标框架执行干净构建(
net9.0或删除dotnet build --no-incremental/bin目录),建立干净基线。记录所有预先存在的警告。obj
Step 2: Update the Target Framework
步骤2:更新目标框架
-
In each(or
.csprojif centralized), change:Directory.Build.propsxml<TargetFramework>net9.0</TargetFramework>to:xml<TargetFramework>net10.0</TargetFramework>For multi-targeted projects, addtonet10.0or replace<TargetFrameworks>.net9.0 -
Update all,
Microsoft.Extensions.*,Microsoft.AspNetCore.*, and other Microsoft package references to their 10.0.x versions. If using Central Package Management (Microsoft.EntityFrameworkCore.*), update versions there.Directory.Packages.props -
Run. Watch for:
dotnet restore- NU1510: Direct references pruned by NuGet — the package may be included in the shared framework now. Remove the explicit if so.
<PackageReference> - PackageReference without a version now raises an error — every must have a
<PackageReference>(or use CPM).Version - NuGet auditing of transitive packages (now audits transitive deps) — review any new vulnerability warnings.
dotnet restore
- NU1510: Direct references pruned by NuGet — the package may be included in the shared framework now. Remove the explicit
-
Run a clean build. Collect all errors and new warnings. These will be addressed in Step 3.
-
在每个(或集中管理的
.csproj)中,将:Directory.Build.propsxml<TargetFramework>net9.0</TargetFramework>修改为:xml<TargetFramework>net10.0</TargetFramework>对于多目标框架项目,在中添加<TargetFrameworks>或替换net10.0。net9.0 -
将所有、
Microsoft.Extensions.*、Microsoft.AspNetCore.*及其他微软包引用更新至10.0.x版本。若使用中央包管理(Microsoft.EntityFrameworkCore.*),则在该文件中更新版本。Directory.Packages.props -
运行。注意以下情况:
dotnet restore- NU1510:NuGet自动移除直接引用——该包现在可能已包含在共享框架中,若如此则移除显式的。
<PackageReference> - 无版本的PackageReference现在会引发错误——每个必须指定
<PackageReference>(或使用CPM)。Version - NuGet会审核传递依赖包(现在会审核传递依赖)——查看任何新的漏洞警告。
dotnet restore
- NU1510:NuGet自动移除直接引用——该包现在可能已包含在共享框架中,若如此则移除显式的
-
执行干净构建。收集所有错误和新警告,这些将在步骤3中处理。
Step 3: Resolve build errors and source-incompatible changes
步骤3:解决构建错误和源代码不兼容变更
Work through compilation errors and new warnings systematically. Load the appropriate reference documents based on the project type:
| If the project uses… | Load reference |
|---|---|
| Any .NET 10 project | |
| Any .NET 10 project | |
| Any .NET 10 project | |
| ASP.NET Core | |
| Entity Framework Core | |
| Cryptography APIs | |
| Microsoft.Extensions.Hosting, BackgroundService, configuration | |
| System.Text.Json, XmlSerializer, HttpClient, MailAddress, Uri | |
| Windows Forms or WPF | |
| Docker containers, single-file apps, native interop | |
Common source-incompatible changes to check for:
-
conflicts — Remove the
System.Linq.Asyncpackage reference or upgrade to v7.0.0. If consumed transitively, addSystem.Linq.Async. Rename<ExcludeAssets>compile</ExcludeAssets>calls toSelectAwaitwhere needed.Select -
New obsoletion warnings (SYSLIB0058–SYSLIB0062):
- : Replace
SYSLIB0058/SslStream.KeyExchangeAlgorithm/CipherAlgorithmwithHashAlgorithm— if the old properties were used to reject weak TLS ciphers, preserve equivalent validation logic using the new APINegotiatedCipherSuite - : Replace
SYSLIB0059withSystemEvents.EventsThreadShutdownAppDomain.ProcessExit - : Replace
SYSLIB0060constructors withRfc2898DeriveBytesRfc2898DeriveBytes.Pbkdf2 - : Replace
SYSLIB0061/Queryable.MaxByoverloads takingMinBywith ones takingIComparer<TSource>IComparer<TKey> - : Replace
SYSLIB0062usageXsltSettings.EnableScript
-
C# 14keyword in property accessors — The identifier
fieldis now a contextual keyword inside propertyfield/get/setaccessors. Local variables namedinitcause CS9272 (error). Class members namedfieldreferenced withoutfieldcause CS9258 (warning). Fix by renaming (e.g.,this.) or escaping withfieldValue. See@field.references/csharp-compiler-dotnet9to10.md -
C# 14contextual keyword — Types, aliases, or type parameters named
extensionare disallowed. Rename or escape withextension.@extension -
C# 14 overload resolution with span parameters — Expression trees containingon arrays may now bind to
.Contains()instead ofMemoryExtensions.Contains.Enumerable.Containson arrays may resolve to the in-placeEnumerable.Reverseextension. Fix by casting toSpan, usingIEnumerable<T>, or explicit static invocations. See.AsEnumerable()for full details.references/csharp-compiler-dotnet9to10.md -
ASP.NET Core obsoletions (if applicable):
- ,
WebHostBuilder,IWebHostare obsolete — migrate toWebHostorHost.CreateDefaultBuilderWebApplication.CreateBuilder - /
IActionContextAccessorobsoleteActionContextAccessor - extension method deprecated
WithOpenApi - property deprecated
IncludeOpenAPIAnalyzers - and
IPNetworkobsoleteForwardedHeadersOptions.KnownNetworks - Razor runtime compilation is obsolete
- package deprecated
Microsoft.Extensions.ApiDescription.Client - v2.x breaking changes —
Microsoft.OpenApipulls inMicrosoft.AspNetCore.OpenApi 10.0v2.x which restructures namespaces and models.Microsoft.OpenApi/OpenApiStringtypes are removed (useOpenApiAny),JsonNodereplaced byOpenApiSecurityScheme.Reference, collections on OpenAPI model objects may be null, andOpenApiSecuritySchemeReferenceis removed. SeeOpenApiSchema.Nullablefor migration patterns.references/aspnet-core-dotnet9to10.md
-
SDK changes:
- now defaults to SLNX format — use
dotnet new slnif the old format is needed--format sln - Double quotes in file-level directives are disallowed
- removed from .NET SDK
dnx.ps1 - no longer supported in
project.jsondotnet restore
-
EF Core source changes (if applicable) — Seefor:
references/efcore-dotnet9to10.md- now accepts a regular lambda (expression tree construction code must be rewritten)
ExecuteUpdateAsync - signature changed
IDiscriminatorPropertySetConvention - methods add
IRelationalCommandDiagnosticsLoggerparameterlogCommandText
-
WinForms/WPF source changes (if applicable):
- Applications referencing both WPF and WinForms must disambiguate and
MenuItemtypesContextMenu - Renamed parameter in
HtmlElement.InsertAdjacentElement - Empty and
ColumnDefinitionsare disallowed in WPFRowDefinitions
- Applications referencing both WPF and WinForms must disambiguate
-
Cryptography source changes (if applicable):
- and
MLDsamembers renamed fromSlhDsatoSecretKey(e.g.,PrivateKey→ExportMLDsaSecretKey,ExportMLDsaPrivateKey→SecretKeySizeInBytes)PrivateKeySizeInBytes - constructors are obsolete (SYSLIB0060) — replace with static
Rfc2898DeriveBytesRfc2898DeriveBytes.Pbkdf2(password, salt, iterations, hashAlgorithm, outputLength) - can now be null — check for null before use
CoseSigner.Key - and
X509Certificate.GetKeyAlgorithmParameters()can return nullPublicKey.EncodedParameters - Environment variable renamed from to
CLR_OPENSSL_VERSION_OVERRIDEDOTNET_OPENSSL_VERSION_OVERRIDE
Build again after each batch of fixes. Repeat until the build is clean.
系统地处理编译错误和新警告。根据项目类型加载对应的参考文档:
| 项目使用的技术 | 加载的参考文档 |
|---|---|
| 任何.NET 10项目 | |
| 任何.NET 10项目 | |
| 任何.NET 10项目 | |
| ASP.NET Core | |
| Entity Framework Core | |
| 加密API | |
| Microsoft.Extensions.Hosting、BackgroundService、配置 | |
| System.Text.Json、XmlSerializer、HttpClient、MailAddress、Uri | |
| Windows Forms或WPF | |
| Docker容器、单文件应用、本地互操作 | |
需要检查的常见源代码不兼容变更:
-
冲突 — 移除
System.Linq.Async包引用或升级至v7.0.0。若为传递依赖,添加System.Linq.Async。必要时将<ExcludeAssets>compile</ExcludeAssets>调用重命名为SelectAwait。Select -
新的弃用警告(SYSLIB0058–SYSLIB0062):
- :用
SYSLIB0058替换NegotiatedCipherSuite/SslStream.KeyExchangeAlgorithm/CipherAlgorithm——如果旧属性用于拒绝弱TLS密码套件,请使用新API保留等效的验证逻辑HashAlgorithm - :用
SYSLIB0059替换AppDomain.ProcessExitSystemEvents.EventsThreadShutdown - :用
SYSLIB0060替换Rfc2898DeriveBytes.Pbkdf2构造函数Rfc2898DeriveBytes - :用接受
SYSLIB0061的重载替换IComparer<TKey>/Queryable.MaxBy中接受MinBy的重载IComparer<TSource> - :替换
SYSLIB0062的使用XsltSettings.EnableScript
-
C# 14属性访问器中的关键字 — 在属性的
field/get/set访问器内部,标识符init现在是上下文关键字。名为field的局部变量会引发CS9272错误。未使用field引用的名为this.的类成员会引发CS9258警告。修复方式为重命名(如field)或使用fieldValue转义。详情见@field。references/csharp-compiler-dotnet9to10.md -
C# 14上下文关键字 — 不允许将类型、别名或类型参数命名为
extension。重命名或使用extension转义。@extension -
C# 14中带span参数的重载解析 — 数组上调用的表达式树现在可能绑定到
.Contains()而非MemoryExtensions.Contains。数组上的Enumerable.Contains可能解析为原地修改的Enumerable.Reverse扩展方法。修复方式为强制转换为Span、使用IEnumerable<T>或显式静态调用。详情见.AsEnumerable()。references/csharp-compiler-dotnet9to10.md -
ASP.NET Core弃用项(若适用):
- 、
WebHostBuilder、IWebHost已弃用——迁移至WebHost或Host.CreateDefaultBuilderWebApplication.CreateBuilder - /
IActionContextAccessor已弃用ActionContextAccessor - 扩展方法已弃用
WithOpenApi - 属性已弃用
IncludeOpenAPIAnalyzers - 和
IPNetwork已弃用ForwardedHeadersOptions.KnownNetworks - Razor运行时编译已弃用
- 包已弃用
Microsoft.Extensions.ApiDescription.Client - v2.x重大变更 —
Microsoft.OpenApi引入了Microsoft.AspNetCore.OpenApi 10.0v2.x,该版本重构了命名空间和模型。Microsoft.OpenApi/OpenApiString类型已移除(使用OpenApiAny替代),JsonNode被OpenApiSecurityScheme.Reference替代,OpenAPI模型对象上的集合可能为null,OpenApiSecuritySchemeReference已移除。迁移模式详情见OpenApiSchema.Nullable。references/aspnet-core-dotnet9to10.md
-
SDK变更:
- 现在默认生成SLNX格式——若需要旧格式请使用
dotnet new sln--format sln - 文件级指令中不允许使用双引号
- .NET SDK中移除了
dnx.ps1 - 不再支持
dotnet restoreproject.json
-
EF Core源代码变更(若适用)——详情见:
references/efcore-dotnet9to10.md- 现在接受常规lambda表达式(需要重写表达式树构造代码)
ExecuteUpdateAsync - 签名变更
IDiscriminatorPropertySetConvention - 方法新增
IRelationalCommandDiagnosticsLogger参数logCommandText
-
WinForms/WPF源代码变更(若适用):
- 同时引用WPF和WinForms的应用必须明确区分和
MenuItem类型ContextMenu - 的参数重命名
HtmlElement.InsertAdjacentElement - WPF中不允许空的和
ColumnDefinitionsRowDefinitions
- 同时引用WPF和WinForms的应用必须明确区分
-
加密源代码变更(若适用):
- 和
MLDsa成员从SlhDsa重命名为SecretKey(如PrivateKey→ExportMLDsaSecretKey,ExportMLDsaPrivateKey→SecretKeySizeInBytes)PrivateKeySizeInBytes - 构造函数已弃用(SYSLIB0060)——替换为静态方法
Rfc2898DeriveBytesRfc2898DeriveBytes.Pbkdf2(password, salt, iterations, hashAlgorithm, outputLength) - 现在可以为null——使用前需检查null
CoseSigner.Key - 和
X509Certificate.GetKeyAlgorithmParameters()可能返回nullPublicKey.EncodedParameters - 环境变量从重命名为
CLR_OPENSSL_VERSION_OVERRIDEDOTNET_OPENSSL_VERSION_OVERRIDE
每修复一批问题后重新构建。重复此过程直到构建干净。
Step 4: Address behavioral changes
步骤4:处理行为变更
Behavioral changes do not cause build errors but may change runtime behavior. Review each applicable item and determine whether the previous behavior was relied upon.
High-impact behavioral changes (check first):
-
SIGTERM signal handling removed — The .NET runtime no longer registers default SIGTERM handlers. If you rely onor
AppDomain.ProcessExitbeing raised on SIGTERM:AssemblyLoadContext.Unloading- ASP.NET Core and Generic Host apps are unaffected (they register their own handlers)
- Console apps and containerized apps without Generic Host must register explicitly
PosixSignalRegistration.Create(PosixSignal.SIGTERM, _ => Environment.Exit(0))
-
BackgroundService.ExecuteAsync runs entirely on a background thread — The synchronous portion before the firstno longer blocks startup. If startup ordering matters, move that code to
awaitor the constructor, or implementStartAsync.IHostedLifecycleService -
Configuration null values are now preserved — JSONvalues are no longer converted to empty strings. Properties initialized with non-default values will be overwritten with
null. Review configuration binding code.null -
Microsoft.Data.Sqlite DateTimeOffset changes (all High impact):
- without an offset now assumes UTC (previously assumed local)
GetDateTimeOffset - Writing into REAL columns now converts to UTC first
DateTimeOffset - with an offset now returns UTC with
GetDateTimeDateTimeKind.Utc - Mitigation: as a temporary workaround
AppContext.SetSwitch("Microsoft.Data.Sqlite.Pre10TimeZoneHandling", true)
-
EF Core parameterized collections —on collections now uses multiple scalar parameters instead of JSON/OPENJSON. May affect query performance for large collections. Mitigation:
.Contains()to revert.UseParameterizedCollectionMode(ParameterTranslationMode.Parameter) -
EF Core JSON data type on Azure SQL — Azure SQL and compatibility level ≥170 now use thedata type instead of
json. A migration will be generated to alter existing columns. Mitigation: set compatibility level to 160 or usenvarchar(max)explicitly.HasColumnType("nvarchar(max)") -
System.Text.Json property name conflict validation — Polymorphic types with properties conflicting with metadata names (,
$type,$id) now throw$ref. AddInvalidOperationExceptionto conflicting properties.[JsonIgnore]
Other behavioral changes to review:
- no longer implicitly flushes — add explicit
BufferedStream.WriteBytecalls if neededFlush() - Default trace context propagator updated to W3C standard
- returns actual Linux filesystem type names
DriveInfo.DriveFormat - LDAP parsing is more stringent
DirectoryControl - Default .NET container images switched from Debian to Ubuntu (Debian images no longer shipped)
- Single-file apps no longer look for native libraries in executable directory by default
- only searches the assembly directory
DllImportSearchPath.AssemblyDirectory - enforces validation for consecutive dots
MailAddress - Streaming HTTP responses enabled by default in browser HTTP clients
- length limits removed — add explicit length validation if
Uriwas used to reject oversized input from untrusted sourcesUri - Cookie login redirects disabled for known API endpoints (ASP.NET Core)
- no longer ignores
XmlSerializerproperties — audit obsolete properties for sensitive data and add[Obsolete]to prevent unintended data exposure[XmlIgnore] - audits transitive packages
dotnet restore - logs to stderr instead of stdout
dotnet watch - CLI commands log non-command-relevant data to stderr
dotnet - Various NuGet behavioral changes (see )
references/sdk-msbuild-dotnet9to10.md - uses System RenderMode by default (WinForms)
StatusStrip - checkbox image truncation fix (WinForms)
TreeView - incorrect usage causes crash (WPF)
DynamicResource
行为变更不会导致构建错误,但可能改变运行时行为。审查每个适用项并确定是否依赖之前的行为。
高影响行为变更(优先检查):
-
移除SIGTERM信号处理 — .NET运行时不再注册默认SIGTERM处理程序。如果依赖或
AppDomain.ProcessExit在SIGTERM时触发:AssemblyLoadContext.Unloading- ASP.NET Core和通用宿主应用不受影响(它们会注册自己的处理程序)
- 控制台应用和未使用通用宿主的容器化应用必须显式注册
PosixSignalRegistration.Create(PosixSignal.SIGTERM, _ => Environment.Exit(0))
-
BackgroundService.ExecuteAsync完全在后台线程运行 — 第一个之前的同步部分不再阻塞启动。如果启动顺序很重要,请将该代码移至
await或构造函数,或实现StartAsync。IHostedLifecycleService -
配置空值现在被保留 — JSON值不再转换为空字符串。使用非默认值初始化的属性会被
null覆盖。审查配置绑定代码。null -
Microsoft.Data.Sqlite DateTimeOffset变更(均为高影响):
- 无偏移量的现在默认使用UTC(之前默认使用本地时间)
GetDateTimeOffset - 将写入REAL列现在会先转换为UTC
DateTimeOffset - 带偏移量的现在返回带
GetDateTime的UTC时间DateTimeKind.Utc - 缓解措施:临时使用作为变通方案
AppContext.SetSwitch("Microsoft.Data.Sqlite.Pre10TimeZoneHandling", true)
- 无偏移量的
-
EF Core参数化集合 — 集合上的现在使用多个标量参数而非JSON/OPENJSON。对于大型集合可能影响查询性能。缓解措施:使用
.Contains()恢复旧行为。UseParameterizedCollectionMode(ParameterTranslationMode.Parameter) -
EF Core在Azure SQL上的JSON数据类型 — Azure SQL及兼容级别≥170现在使用数据类型而非
json。会生成迁移来修改现有列。缓解措施:将兼容级别设置为160或显式使用nvarchar(max)。HasColumnType("nvarchar(max)") -
System.Text.Json属性名称冲突验证 — 与元数据名称(、
$type、$id)冲突的多态类型属性现在会抛出$ref。为冲突属性添加InvalidOperationException。[JsonIgnore]
其他需要审查的行为变更:
- 不再隐式刷新——必要时添加显式
BufferedStream.WriteByte调用Flush() - 默认跟踪上下文传播器更新为W3C标准
- 返回实际的Linux文件系统类型名称
DriveInfo.DriveFormat - LDAP解析更严格
DirectoryControl - 默认.NET容器镜像从Debian切换为Ubuntu(不再提供Debian镜像)
- 单文件应用默认不再在可执行目录中查找本地库
- 仅搜索程序集目录
DllImportSearchPath.AssemblyDirectory - 强制验证连续点
MailAddress - 浏览器HTTP客户端默认启用流式HTTP响应
- 长度限制已移除——如果之前使用
Uri拒绝来自不可信来源的超大输入,请添加显式长度验证Uri - 已知API端点默认禁用Cookie登录重定向(ASP.NET Core)
- 不再忽略
XmlSerializer属性——审查包含敏感数据的弃用属性,添加[Obsolete]以防止意外数据泄露[XmlIgnore] - 审核传递依赖包
dotnet restore - 现在将日志输出到stderr而非stdout
dotnet watch - CLI命令将与命令无关的数据输出到stderr
dotnet - 各种NuGet行为变更(见)
references/sdk-msbuild-dotnet9to10.md - 默认使用系统渲染模式(WinForms)
StatusStrip - 修复复选框图像截断问题(WinForms)
TreeView - 错误使用会导致崩溃(WPF)
DynamicResource
Step 5: Update infrastructure
步骤5:更新基础设施
-
Dockerfiles: Update base images. Default tags now use Ubuntu instead of Debian. Debian images are no longer shipped for .NET 10.dockerfile
# Before FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build FROM mcr.microsoft.com/dotnet/aspnet:9.0 # After FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build FROM mcr.microsoft.com/dotnet/aspnet:10.0 -
CI/CD pipelines: Update SDK version references. If using, update:
global.jsonjson{ "sdk": { "version": "10.0.100" } } -
Environment variables renamed:
- replaces the old name
DOTNET_OPENSSL_VERSION_OVERRIDE - replaces the old name
DOTNET_ICU_VERSION_OVERRIDE - has been removed
NUGET_ENABLE_ENHANCED_HTTP_RETRY
-
OpenSSL requirements: OpenSSL 1.1.1 or later is now required on Unix. OpenSSL cryptographic primitives are no longer supported on macOS.
-
Solution file format: Ifis used in scripts, note it now generates SLNX format. Pass
dotnet new slnif the old format is needed.--format sln
-
Dockerfile:更新基础镜像。默认标签现在使用Ubuntu而非Debian。.NET 10不再提供Debian镜像。dockerfile
# 之前 FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build FROM mcr.microsoft.com/dotnet/aspnet:9.0 # 之后 FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build FROM mcr.microsoft.com/dotnet/aspnet:10.0 -
CI/CD流水线:更新SDK版本引用。若使用,更新为:
global.jsonjson{ "sdk": { "version": "10.0.100" } } -
重命名的环境变量:
- 替代旧名称
DOTNET_OPENSSL_VERSION_OVERRIDE - 替代旧名称
DOTNET_ICU_VERSION_OVERRIDE - 已被移除
NUGET_ENABLE_ENHANCED_HTTP_RETRY
-
OpenSSL要求:Unix系统现在需要OpenSSL 1.1.1或更高版本。macOS不再支持OpenSSL加密原语。
-
解决方案文件格式:如果脚本中使用,注意现在默认生成SLNX格式。若需要旧格式,请传递
dotnet new sln参数。--format sln
Step 6: Verify
步骤6:验证
- Run a full clean build:
dotnet build --no-incremental - Run all tests:
dotnet test - If the application is containerized, build and test the container image
- Smoke-test the application, paying special attention to:
- Signal handling / graceful shutdown behavior
- Background services startup ordering
- Configuration binding with null values
- Date/time handling with Sqlite
- JSON serialization with polymorphic types
- EF Core queries using on collections
.Contains()
- Security review — verify that the migration has not weakened security controls:
- TLS cipher validation logic is preserved after API migration (SYSLIB0058)
SslStream - Obsolete properties containing sensitive data are excluded from serialization (,
[XmlIgnore])[JsonIgnore] - Input validation still rejects oversized URIs if was used as a length gate
Uri - Exception handlers emit security-relevant telemetry (auth failures, access violations) before returning
true - Connection strings set an explicit that does not leak version info
Application Name - vulnerability audit findings are addressed, not suppressed
dotnet restore
- TLS cipher validation logic is preserved after
- Review the diff and ensure no unintended behavioral changes were introduced
- 执行完整的干净构建:
dotnet build --no-incremental - 运行所有测试:
dotnet test - 如果应用是容器化的,构建并测试容器镜像
- 对应用进行冒烟测试,特别注意:
- 信号处理/优雅关闭行为
- 后台服务启动顺序
- 带空值的配置绑定
- Sqlite的日期/时间处理
- 多态类型的JSON序列化
- EF Core中使用的集合查询
.Contains()
- 安全审查 — 验证迁移未削弱安全控制:
- 迁移API(SYSLIB0058)后,TLS密码套件验证逻辑是否保留
SslStream - 包含敏感数据的弃用属性是否已排除在序列化之外(、
[XmlIgnore])[JsonIgnore] - 如果之前使用作为长度限制,是否添加了显式长度验证以拒绝超大输入
Uri - 异常处理程序在返回前是否输出了安全相关遥测(认证失败、访问违规)
true - 连接字符串是否设置了明确的,未泄露版本信息
Application Name - 的漏洞审计结果是否已处理,而非被压制
dotnet restore
- 迁移
- 审查差异,确保未引入意外的行为变更
Reference Documents
参考文档
The folder contains detailed breaking change information organized by technology area. Load only the references relevant to the project being migrated:
references/| Reference file | When to load |
|---|---|
| Always (C# 14 compiler breaking changes — field keyword, extension keyword, span overloads) |
| Always (applies to all .NET 10 projects) |
| Always (SDK and build tooling changes) |
| Project uses ASP.NET Core |
| Project uses Entity Framework Core or Microsoft.Data.Sqlite |
| Project uses System.Security.Cryptography or X.509 certificates |
| Project uses Generic Host, BackgroundService, or Microsoft.Extensions.Configuration |
| Project uses System.Text.Json, XmlSerializer, HttpClient, or networking APIs |
| Project uses Windows Forms or WPF |
| Project uses Docker containers, single-file publishing, or native interop (P/Invoke) |
references/| 参考文件 | 加载场景 |
|---|---|
| 始终加载(C# 14编译器重大变更——field关键字、extension关键字、span重载) |
| 始终加载(适用于所有.NET 10项目) |
| 始终加载(SDK和构建工具变更) |
| 项目使用ASP.NET Core |
| 项目使用Entity Framework Core或Microsoft.Data.Sqlite |
| 项目使用System.Security.Cryptography或X.509证书 |
| 项目使用通用宿主、BackgroundService或Microsoft.Extensions.Configuration |
| 项目使用System.Text.Json、XmlSerializer、HttpClient或网络API |
| 项目使用Windows Forms或WPF |
| 项目使用Docker容器、单文件发布或本地互操作(P/Invoke) |