Skip to main content
.NETStandard2.0

用于在 Windows 上辅助 PublishAot 交叉编译到多个 linux RID 的 Nuget 包.

Published
Jun 27, 2026
3mo ago
Total Downloads
1.6K
1,644

Install

dotnet add package PublishAotClang --version 1.0.5
ProductVersions
.NET Standard
netstandard2.0

README

PublishAotClang

这是一个由 Zig 包装成 Clang 工具链环境的 NuGet 包,用于在 Windows 上辅助 PublishAot 交叉编译到多个 linux RID,本项目源于 MichalStrehovsky/PublishAotCross。

新特性

工作项 说明
内置 zig 工具链 引用 Vezel.Zig.Toolsets,Windows 环境下无需单独安装 zig
内置 objcopy 工具 默认支持 Native AOT 的符号裁剪(strip),减少最终二进制体积
内置 libz 静态库 由 zig build zlib-1.3.2 得到,弥补.NET 8.0 AOT发布时未自带 libz 的问题
支持 glibc 版本指定 例如 <GLibcVersion>2.17</GLibcVersion>,.NET 10 项目也可运行于 CentOS 7 等老系统
重写 clang 包装工具 C# 重写,严格处理 clang 参数,增加移除 -Wl,--export-dynamic,避免不必要的全局符号导出
增加 ar 包装工具 C# 编写,支持 <NativeLib>Static</NativeLib> 的静态库项目进行 AOT 发布

如何使用

  1. 在 Native AOT 的项目中,添加对此 NuGet 包的引用。

  2. 在 Windows 机器上,可以额外 AOT 发布到以下 RID:

  • dotnet publish -r linux-x64
  • dotnet publish -r linux-arm64
  • dotnet publish -r linux-arm (.NET 9+)
  • dotnet publish -r linux-musl-x64
  • dotnet publish -r linux-musl-arm64
  • dotnet publish -r linux-musl-arm (.NET 9+)

Changes from Previous Version

No structural changes between v1.0.4 and v1.0.5.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.