.NET 8 发布第三个预览版

1,347次阅读
没有评论

.NET 8 Preview 3 现已推出,这个预览版包括对构建路径、工作负载、Microsoft.Extensions 和容器的更改,还包括针对 Arm64 的 JIT 和动态 PGO 的性能改进。

以下为该预览版的部分改动:

SDK 改动

对 SDK 进行了多项改进,并进行了重大更改。

有关重大更改的更多信息,请参阅 .NET SDK 不再更改退出时的编码

简化输出路径 

.NET SDK 引入了一个选项来创建更统一、更简化的输出路径结构。新的输出路径侧重于:

  • 将所有构建输出收集在一个公共位置
  • 在公共位置下按项目分隔构建输出
  • 将整体构建输出布局展平到最多三层深度

要选择新的输出路径布局,需要在 Directory.Build.props 文件中设置 UseArtifactsOutput 属性。

开始的最简单方法是在存储库的根目录中运行 dotnet new buildprops ,打开生成的 Directory.Build.props 文件,然后将以下内容添加到该文件中的 PropertyGroup :

<UseArtifactsOutput>true</UseArtifactsOutput>

此后,所有项目的构建输出都将放入存储库根目录中的 .artifacts 目录中,该目录可配置,只需将 Directory.Build.props 文件中的 ArtifactsPath 属性设置为其他目录。

.artifacts 目录的布局将采用 <ArtifactsPath><Type of Output><Project Name><Pivots> 形式。

新的dotnet workload clean 命令 

新的命令,可帮助清理剩余的工作负载包(工作负载所包含的实际功能、工具和模板单元):

dotnet workload clean

clean 有两种操作模式,分别是:

dotnet workload clean

这个模式为基于文件或基于 MSI 的工作负载运行工作负载垃圾收集。在这种模式下,垃圾收集行为正常,只清理孤立的包本身。

dotnet workload clean --all

与 workload clean 不同, workload clean –all 不定期运行垃圾回收,这意味着它会清除机器上所有,不是来自 Visual Studio 且属于当前 SDK 工作负载安装类型(基于文件或基于 MSI)的现有包。

运行时改动

引入验证选项结果生成器 (ValidateOptionsResultBuilder)

新的 ValidateOptionsResultBuilder 使创建 ValidateOptionsResult 对象变得更容易,这是实现 IValidateOptions.Validate(String, TOptions) 所必需的。

此构建器允许累积多个错误,然后一次查看所有问题,并相应地解决它们。

使用示例:

ValidateOptionsResultBuilder builder = new();
builder.AddError("Error: invalid operation code");
builder.AddResult(ValidateOptionsResult.Fail("Invalid request parameters"));
builder.AddError("Malformed link", "Url");

// Build ValidateOptionsResult object has accumulating multiple errors.
ValidateOptionsResult result = builder.Build();

// Reset the builder to allow using it in new validation operation.
builder.Clear();

引入配置绑定源码生成器(the configuration binding source generator)

使用新的配置绑定源代码生成器,可自动生成无反射和 AOT 友好的绑定实现。

该生成器会探测 Configure 、 Bind 和 Get 调用,可以从中检索类型信息。

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
IConfigurationSection section = builder.Configuration.GetSection(“MyOptions”);

// !! Configure call – to be replaced with source-gen’d implementation
builder.Services.Configure<MyOptions>(section);

// !! Get call – to be replaced with source-gen’d implementation
MyOptions options0 = section.Get<MyOptions>();

// !! Bind call – to be replaced with source-gen’d implementation
MyOptions options1 = new MyOptions();
section.Bind(myOptions1);

WebApplication app = builder.Build();
app.MapGet(“/”, () => “Hello World!”);
app.Run();

public class MyOptions
{
public int A { get; set; }
public string S { get; set; }
public byte[] Data { get; set; }
public Dictionary<string, string> Values { get; set; }
public List<MyClass> Values2 { get; set; }
}

public class MyClass
{
public int SomethingElse { get; set; }
}

在项目中启用生成器时,编译器会隐式地选择生成的方法,而不是预先存在的基于反射的框架实现。

要启用该源代码生成器,请下载 Microsoft.Extensions.Configuration.Binder 的最新预览版。生成器默认关闭。要使用它,请将以下属性添加到项目文件中:

<PropertyGroup>
<EnableMicrosoftExtensionsConfigurationBinderSourceGenerator>true</EnableMicrosoftExtensionsConfigurationBinderSourceGenerator>
</PropertyGroup>

.NET 8 将在第四个预览版向 .NET SDK 添加启用机制,不需要 NuGet 包引用也可以使用源代码生成器。

本机代码生成 Native code generation

对 JIT 编译器进行了以下改进:

Arm64 

  •  OR(condition, condition) 转换为 CCMP 。它允许 JIT 在 arm64 上发出 CCMP 以进行按位或关系比较。PR#83089 
  • 为 arm64 优化了 x < 0  x >= 0  PR #83176 
  • 优化了除法在某些场景的溢出检查。PR #82924

配置文件引导优化

 

其他容器镜像等优化可在微软博客中了解详情。

Read More 

正文完
可以使用微信扫码关注公众号(ID:xzluomor)
post-qrcode
 0
评论(没有评论)

文心AIGC

2023 年 4 月
 12
3456789
10111213141516
17181920212223
24252627282930
文心AIGC
文心AIGC
人工智能ChatGPT,AIGC指利用人工智能技术来生成内容,其中包括文字、语音、代码、图像、视频、机器人动作等等。被认为是继PGC、UGC之后的新型内容创作方式。AIGC作为元宇宙的新方向,近几年迭代速度呈现指数级爆发,谷歌、Meta、百度等平台型巨头持续布局
文章搜索
热门文章
潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026

潞晨尤洋:日常办公没必要上私有模型,这三类企业才需要 | MEET2026 Jay 2025-12-22 09...
面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25

面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25

面向「空天具身智能」,北航团队提出星座规划新基准丨NeurIPS’25 鹭羽 2025-12-13 22:37...
商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1

商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1

商汤Seko2.0重磅发布,合作短剧登顶抖音AI短剧榜No.1 十三 2025-12-15 14:13:14 ...
跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026 一水 2025-1...
10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了 一水 2025-12-12 13:56:19 ...
最新评论
ufabet ufabet มีเกมให้เลือกเล่นมากมาย: เกมเดิมพันหลากหลาย ครบทุกค่ายดัง
tornado crypto mixer tornado crypto mixer Discover the power of privacy with TornadoCash! Learn how this decentralized mixer ensures your transactions remain confidential.
ดูบอลสด ดูบอลสด Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Pretty! This has been a really wonderful post. Many thanks for providing these details.
ดูบอลสด ดูบอลสด Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
Obrazy Sztuka Nowoczesna Obrazy Sztuka Nowoczesna Thank you for this wonderful contribution to the topic. Your ability to explain complex ideas simply is admirable.
ufabet ufabet Hi there to all, for the reason that I am genuinely keen of reading this website’s post to be updated on a regular basis. It carries pleasant stuff.
ufabet ufabet You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
ufabet ufabet Very well presented. Every quote was awesome and thanks for sharing the content. Keep sharing and keep motivating others.
热评文章
跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026

跳过“逐字生成”!蚂蚁集团赵俊博:扩散模型让我们能直接修改Token | MEET2026 一水 2025-1...
10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了

10亿美元OpenAI股权兑换迪士尼版权!米老鼠救Sora来了 一水 2025-12-12 13:56:19 ...
IDC MarketScape: 容联云位居“中国AI赋能的联络中心”领导者类别

IDC MarketScape: 容联云位居“中国AI赋能的联络中心”领导者类别

IDC MarketScape: 容联云位居“中国AI赋能的联络中心”领导者类别 量子位的朋友们 2025-1...