new|正式发布 | .NET 7 预览版 2
点击上方蓝字
关注我们
(本文阅读所需15分钟)
今天 , 我们很高兴发布 .NET 7 预览版 2 。 .NET 7 的第二个预览版包括对 RegEx 源生成器的增强、将 NativeAOT 从实验状态转移到运行时的进展 , 以及对“dotnet new”CLI 的一系列重大改进经验 。 这些可供您立即获取并开始尝试新功能 , 例如:
- 在编译时使用源生成器而不是在运行时使用较慢的方法来构建专门的 RegEx 模式匹配引擎 。
- dotnet new 利用 SDK 改进提供全新的简化选项卡完成体验来探索模板和参数 。
- 用你自己的创新解决方案尝试 NativeAOT 。
▌ 引入新的正则表达式源生成器
新正则表达式源生成器带来了我们编译引擎的更多性能优势 , 而无需额外成本 , 它还可以提供出色的调试体验以及便于修剪 。 如果您的模式在编译时是已知的 , 那么新的正则表达式源生成器可以很好地帮到您 。
您只需要将包含类型转换为部分类型 , 并使用 RegexGenerator 属性声明一个新的部分方法 , 该方法将返回优化的 Regex 对象 。 源代码生成器将为您填充该方法的实现 , 并在您更改模式或传入的其他选项时自动更新 。
更新前
更新后
▌SDK 改进
- [Epic] 新的 CLI 解析器 + 选项卡完成 #2191
以下是新的帮助输出示例:
Arguments:< template- short-name> A shortname of the templateto create. < template-args> Template specific options to use.
Options:-?, -h, --help Show command line help.
【new|正式发布 | .NET 7 预览版 2】Commands:install <package> Installs a templatepackage. uninstall <package> Uninstalls a templatepackage. update Checks the currently installed templatepackages forupdate, andinstall the updates. search < template-name> Searches forthe templates on NuGet.org. list< template-name> Lists templates containing the specified templatename. If no name is specified, lists all templates.
- 新命令名称
- Tab自动补全
- 可用的模板名称(in dotnet new <template-short-name>)
- 模板选项( Web模板中的模板选项列表)
- 这些模板选项的允许值(选择模板参数上的选择值)
- 未来的工作
- 下一步是什么
- NativeAOT 更新
该工作现已完成 , 但我们尚未在 dotnet SDK 中添加支持 , 来使用 NativeAOT 发布项目 。 我们希望尽快完成这项工作 , 以便您可以在您的应用程序中试用 NativeAOT 。 同时 , 请尝试修剪您的应用并确保没有修剪警告 。 修剪是 NativeAOT 的要求 。 如果您拥有任何库 , 请参考准备进行修剪库的说明 。
- 引入新的正则表达式源生成器
https://github.com/dotnet/runtime/issues/44676
- [Epic] 新的 CLI 解析器 + 选项卡完成 #2191
https://github.com/dotnet/templating/issues/2191
- 如何为 .NET CLI 启用 TAB 补全
https://docs.microsoft.com/dotnet/core/tools/enable-tab-autocomplete
- dotnet/templating 存储库中问题解决方案
https://github.com/dotnet/templating/issues/2191
- NativeAOT 项目
https://github.com/dotnet/runtime/issues/61231
- dotnet/runtimelab repo中移出
https://github.com/dotnet/runtimelab
- dotnet/runtime
https://github.com/dotnet/runtimelab
- 应用
https://docs.microsoft.com/dotnet/core/deploying/trimming/trim-self-contained
- 准备进行修剪库的说明
https://docs.microsoft.com/dotnet/core/deploying/trimming/prepare-libraries-for-trimming
要targeting .NET 7 , 您需要在项目文件中使用 .NET 7 Target Framework Moniker (TFM) 。 例如:
<TargetFramework> net7.0 </TargetFramework>
全套 .NET 7 TFM , 包括特定于操作系统的 TFM 。
- net7.0
- net7.0-android
- net7.0-ios
- net7.0-maccatalyst
- net7.0-macos
- net7.0-tvos
- net7.0-windows
支持
.NET 7 是当前版本 , 这意味着它将在发布之日起 18 个月内获得免费支持和补丁 。 请务必注意 , 所有版本的质量都是相同的 。 唯一的区别是支持的时间 。 有关 .NET 支持政策的更多信息 , 请参阅.NET 和 .NET Core 官方支持政策 。
- .NET 和 .NET Core 官方支持政策
https://dotnet.microsoft.com/platform/support/policy/dotnet-core
您可以通过阅读 .NET 7 中的重大更改文档找到最新的 .NET 7 重大更改列表 。 它按区域和版本列出了重大更改 , 并附有详细说明的链接 。
要查看提出了哪些重大更改但仍在审核中 , 请关注Proposed .NET Breaking Changes GitHub 问题 。
- .最新的 .NET 7 重大更改列表 https://docs.microsoft.com/dotnet/core/compatibility/7.0
- .Proposed .NET Breaking Changes GitHub 问题 https://github.com/dotnet/core/issues/7131
.NET 版本包括产品、库、运行时和工具 , 代表了 Microsoft 内外多个团队之间的协作 。 您可以通过阅读产品路线图了解有关这些领域的更多信息:
- ASP.NET Core 7 和 Blazor 路线图 https://github.com/dotnet/aspnetcore/issues/39504
- EF 7 路线图 https://docs.microsoft.com/ef/core/what-is-new/ef-core-7.0/plan
- ML.NET https://github.com/dotnet/machinelearning/blob/main/ROADMAP.md
- .NET MAUI https://github.com/dotnet/maui/wiki/Roadmap
- WinForms https://github.com/dotnet/winforms/blob/main/docs/roadmap.md
- WPF https://github.com/dotnet/wpf/blob/main/roadmap.md
- NuGet https://github.com/NuGet/Home/issues/11571
- Roslyn https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md
- Runtime https://github.com/dotnet/core/blob/main/r oadmap.md
EF7 预览版 2 也已发布 , 可在 NuGet 上使用 。 您还可以阅读 ASP.NET Core 预览版 2 中的新增功能 。 您可以下载适用于 Windows、macOS 和 Linux 的.NET 7 预览版 2。 如果您想在 Visual Studio 系列产品中试用 .NET 7 , 我们建议您使用预览频道版本 。 Visual Studio for Mac 对 .NET 7 预览版的支持尚不可用 , 但即将推出 。
- . 可在 NuGet 上使用 https://www.nuget.org/packages/Microsoft.EntityFrameworkCore/7.0.0-preview.2.22153.1
- ASP.NET Core 预览版 2 中的新增功能 https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-7-preview-2/
- .NET 7 预览版 2 https://dotnet.microsoft.com/download/dotnet/7.0
- 安装程序和二进制文件 https://dotnet.microsoft.com/download/dotnet/7.0
- 容器图像 https://github.com/dotnet/core/blob/master/release-notes/7.0/
- Linux 软件包 https://github.com/dotnet/core/blob/master/release-notes/7.0/
- 发行说明 https://github.com/dotnet/core/tree/master/release-notes/7.0
- 已知的问题 https://github.com/dotnet/core/blob/main/release-notes/7.0/known-issues.md
- GitHub 问题跟踪器 https://github.com/dotnet/core/issues
- 预览频道版本 https://visualstudio.com/preview
谢谢你读完了本文~相信你一定有一些感想、观点、问题想要表达 。 欢迎在评论区畅所欲言 , 期待听到你的“声音”哦!
同时 , 喜欢的内容也不要忘记转发给你的小伙伴们 , 谢谢你的支持!
关注微软中国MSDN
下载.NET 7 预览版2
推荐阅读
- 菜单|微软 Win11 发布 Build 22579 更新:带来新的开始菜单功能
- Windows|[图]Windows 11 Build 22579发布:可将移动磁盘排除在加密之外
- 四大|Redmi K40S真香机发布,带来四大升级,起售价只要1799元
- Lenovo|联想ThinkBook 14+发布:2.8K屏 支持180°开合
- Google|Roskomnadzor警告YouTube停止发布对抗俄罗斯的信息与广告
- 家居|欧瑞博发布7寸家居智能语音屏,将兼容全新Matter协议生态
- Lenovo|4999元起 联想ThinkBook 16+发布:12代标压酷睿 2.5K高刷屏
- 手机|红米K50发布,推动高端产品大众化?海外市场如何发展?
- 产品|Secure DevOps!探真科技2022云原生安全产品发布会圆满落幕
- 通信技术|亚马逊云科技宣布新的量子处理单元Lucy正式可用