Announcing .NET 11

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Today, we’re excited to announce the release of .NET 11! This year’s release makes building modern applications faster, more productive, and has improvements across C# 15, ASP.NET Core, .NET MAUI, and Windows development. With hundreds of runtime optimizations, more responsive SDK tooling, and less overhead in everyday commands, you can spend less time waiting and more time creating. Build richer web and cross-platform applications, take advantage of new C# language features, and explore AI-powered development with improved tools and agentic capabilities.

今天,我们很高兴宣布 .NET 11 的发布!今年的版本使构建现代应用程序变得更快、更高效,并在 C# 15、ASP.NET Core、.NET MAUI 和 Windows 开发方面进行了改进。通过数百项运行时优化、响应更迅速的 SDK 工具以及日常命令中更少的开销,您可以减少等待时间,将更多时间用于创作。构建更丰富的 Web 和跨平台应用程序,利用新的 C# 语言特性,并通过改进的工具和代理能力探索人工智能驱动的开发。

Download .NET 11 .NET 11 support .NET 11 is a Standard Term Support (STS) release with two years of support under the .NET support policy. STS and Long Term Support (LTS) releases have the same quality and servicing policies; the difference is the length of support. .NET 10 remains a supported LTS option. Stay current with servicing updates whichever release you choose.

下载 .NET 11。关于 .NET 11 的支持:.NET 11 是一个标准期限支持 (STS) 版本,根据 .NET 支持策略提供两年的支持。STS 和长期支持 (LTS) 版本具有相同的质量和服务策略;区别在于支持时长。 .NET 10 仍然是一个受支持的 LTS 选项。无论您选择哪个版本,请务必通过服务更新保持最新状态。

Join us at .NET Conf, November 10-13 Explore .NET 11 with the product teams and community at .NET Conf 2026. The conference includes product team sessions on November 10 and 11, followed by two days of community sessions. Watch the Day 1 livestream, including the keynote, or browse the conference session playlist.

欢迎参加 11 月 10 日至 13 日举行的 .NET Conf。在 2026 年 .NET Conf 上与产品团队和社区一起探索 .NET 11。会议包括 11 月 10 日和 11 日的产品团队会议,随后是为期两天的社区会议。观看包括主题演讲在内的第一天直播,或浏览会议议程播放列表。

Announcing .NET 11 Watch .NET Conf What’s new in .NET 11 Some of the changes we’re most excited for you to try: C# 15 union types and closed hierarchies help you express the possible states of your application and handle them with compiler-checked patterns. A Native AOT CLI host and a warm MSBuild server reduce overhead in everyday developer workflows. ASP.NET Core brings asynchronous validation, OpenAPI 3.2, and new capabilities for Blazor and SignalR applications. Experimental Blazor AI components integrate with the Agent User Interaction Protocol (AG-UI) for advanced agentic web experiences. Build AI-powered, agentic applications with Microsoft.Extensions.AI (MEAI) for model access, MCP for tool integration, and Microsoft Agent Framework (MAF) for agents and workflows. Put agentic development tools to work with .NET Skills for .NET-specific guidance, .NET MAUI DevFlow for inspecting and testing running apps, and the .NET Upgrade canvas for reviewing modernization progress. .NET MAUI adopts CoreCLR as its default runtime and improves XAML iteration and native controls. The libraries add built-in Zstandard compression, simpler process execution, richer JSON support, and new ways to work with in-memory data without copying it first. The what’s new in .NET 11 overview links to the full details. Here are the changes behind those headlines and how to start using them.

宣布 .NET 11。观看 .NET Conf。.NET 11 的新功能:我们最期待您尝试的一些变化包括:C# 15 的联合类型和封闭层次结构可帮助您表达应用程序的可能状态,并使用编译器检查的模式来处理它们。原生 AOT CLI 主机和预热的 MSBuild 服务器减少了日常开发工作流中的开销。ASP.NET Core 带来了异步验证、OpenAPI 3.2 以及针对 Blazor 和 SignalR 应用程序的新功能。实验性的 Blazor AI 组件与代理用户交互协议 (AG-UI) 集成,以实现高级的代理 Web 体验。使用 Microsoft.Extensions.AI (MEAI) 进行模型访问、使用 MCP 进行工具集成以及使用 Microsoft Agent Framework (MAF) 进行代理和工作流构建,从而构建人工智能驱动的代理应用程序。利用 .NET Skills 获取特定于 .NET 的指导,使用 .NET MAUI DevFlow 检查和测试正在运行的应用程序,并使用 .NET Upgrade 画布审查现代化进度,从而应用代理开发工具。.NET MAUI 采用 CoreCLR 作为其默认运行时,并改进了 XAML 迭代和原生控件。库中增加了内置的 Zstandard 压缩、更简单的进程执行、更丰富的 JSON 支持,以及在不先复制的情况下处理内存中数据的新方法。.NET 11 新功能概述链接到了完整详细信息。以下是这些标题背后的变化以及如何开始使用它们。

Languages C# 15 C# 15 is the default language version for projects targeting .NET 11. Union types are one of its biggest additions: a value can be one of a declared set of case types, with conversions from those types and exhaustiveness checking in switch expressions. Consider a product lookup that either finds a product or reports that it wasn’t found: ProductLookup result = new Product(42, “Mechanical keyboard”); string message = result switch { Product product => $“Found {product.Name}”, ProductNotFound missing => $“No product with ID {missing.Id}”, }; Console.WriteLine(message); public sealed record Product(int Id, string Name); public sealed record ProductNotFound(int Id); public union ProductLookup(Product, ProductNotFound); The result type tells a caller which outcomes it needs to handle. There’s no need to use object or an unrelated base class just to put those outcomes behind one return type. C# 15 also adds closed hierarchies. A closed class limits direct derivation to its declaring assembly, giving the compiler the information it needs to check patterns over the hierarchy. Unions are useful when you want to combine existing types; closed hierarchies fit models where you own the inheritance relationship.

语言 C# 15:C# 15 是针对 .NET 11 的项目的默认语言版本。联合类型是其最大的新增功能之一:一个值可以是声明的一组情况类型之一,并支持从这些类型进行转换,以及在 switch 表达式中进行穷举检查。考虑一个产品查找功能,它要么找到产品,要么报告未找到:ProductLookup result = new Product(42, “Mechanical keyboard”); string message = result switch { Product product => $“Found {product.Name}”, ProductNotFound missing => $“No product with ID {missing.Id}”, }; Console.WriteLine(message); public sealed record Product(int Id, string Name); public sealed record ProductNotFound(int Id); public union ProductLookup(Product, ProductNotFound); 结果类型告诉调用者它需要处理哪些结果。无需为了将这些结果放在一个返回类型之后而使用 object 或不相关的基类。C# 15 还增加了封闭层次结构。封闭类将直接派生限制在其声明程序集中,从而为编译器提供检查层次结构模式所需的信息。当您想要组合现有类型时,联合类型非常有用;封闭层次结构则适用于您拥有继承关系的模型。

Smaller language features help with everyday code, too. Collection expression arguments let you pass constructor or factory arguments without giving up collection expression syntax: HashSet names = [with(StringComparer.OrdinalIgnoreCase), “Alice”, “ALICE”, “Bob”]; Console.WriteLine(names.Count); This prints 2: the comparer controls equality, so “Alice” and “ALICE” are one entry. Other additions include extension indexers and labeled break and continue. These features don’t require the preview language version. The separate memory safety work remains in preview; see the C# 15 feature documentation for its opt-in requirements.

较小的语言特性也有助于日常编码。集合表达式参数允许您传递构造函数或工厂参数,而无需放弃集合表达式语法:HashSet names = [with(StringComparer.OrdinalIgnoreCase), “Alice”, “ALICE”, “Bob”]; Console.WriteLine(names.Count); 这将打印 2:比较器控制相等性,因此 “Alice” 和 “ALICE” 是同一个条目。其他新增功能包括扩展索引器以及带标签的 break 和 continue。这些功能不需要预览语言版本。单独的内存安全工作仍处于预览阶段;请参阅 C# 15 功能文档以了解其选择加入要求。

F# 11 F# 11 improves compiler memory use and reduces allocations in FSharp.Core collection operations. It also adds ways to bound concurrent asynchronous work, useful when a collection operation would otherwise start more work than a service or machine can handle comfortably. The F# release notes distinguish the default-language updates from preview capabilities, including Runtime Async support for custom computation-expression builders.

F# 11:F# 11 改进了编译器内存使用,并减少了 FSharp.Core 集合操作中的分配。它还增加了限制并发异步工作的方法,这在集合操作可能启动超出服务或机器处理能力的工作时非常有用。F# 发行说明区分了默认语言更新和预览功能,包括对自定义计算表达式构建器的运行时异步支持。

Platform SDK The SDK now enables a Native AOT CLI host by default. Commands such as help and version queries can run without starting the managed CLI, and tool launches can avoid that startup path too. Commands that need managed execution still use it. The MSBuild server also stays warm between CLI invocations by default, reducing repeated startup work. SDK installers on Linux and macOS are smaller through assembly deduplication. File-based apps can grow across source files with #:include, and solution filters can be created and edited from the CLI. dotnet watch adds Aspire app-host integration, crash recovery, and device selection for mobile projects. For teams using Microsoft.Testing.Platform, dotnet test gains run-level timeouts, failure limits, clearer progress reporting, and per-module results directories. The test runner matters: these switches aren’t interchangeable with the VSTest command-line options. Container publishing adds reproducible image digests through SOURCE_DATE_EPOCH and avoids redundant layer uploads when t

平台 SDK:SDK 现在默认启用原生 AOT CLI 主机。诸如帮助和版本查询之类的命令可以在不启动托管 CLI 的情况下运行,工具启动也可以避免该启动路径。需要托管执行的命令仍会使用它。MSBuild 服务器在 CLI 调用之间默认保持预热状态,从而减少了重复的启动工作。通过程序集去重,Linux 和 macOS 上的 SDK 安装程序变得更小。基于文件的应用程序可以通过 #:include 在源文件中扩展,并且可以从 CLI 创建和编辑解决方案过滤器。dotnet watch 增加了 Aspire 应用主机集成、崩溃恢复以及针对移动项目的设备选择。对于使用 Microsoft.Testing.Platform 的团队,dotnet test 获得了运行级超时、失败限制、更清晰的进度报告以及每个模块的结果目录。测试运行程序很重要:这些开关不能与 VSTest 命令行选项互换。容器发布通过 SOURCE_DATE_EPOCH 增加了可重现的镜像摘要,并避免了在 t 时进行冗余的层上传。