记一个.NET AOT交叉编译时的坑

记一个.NET AOT交叉编译时的坑

背景:

使用.NET9开发的Avalonia项目需要部署到Linux-arm64

踩坑:

根据官方AOT交叉编译文档配置后执行打包

shell 复制代码
dotnet publish -r linux-arm64

提示error : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative

找答案:

通过在Github上查找,找到了一个AOT交叉编译的文档

这个文档指出了如果需要交叉编译到对应的编译器,需要对应的ILCompiler包,如果需要交叉编译到Linux-arm64,则需要runtime.linux-arm64.Microsoft.DotNet.ILCompiler包

解决:

添加runtime.linux-arm64.Microsoft.DotNet.ILCompilerNUGET包后再执行dotnet publish -r linux-arm64,编译成功

后续:

编译成功后再删除runtime.linux-arm64.Microsoft.DotNet.ILCompiler包引用,再次执行交叉编译,貌似也能成功,可能只是需要这个包把对应的ILCompiler下载回来,后续就不用特别引用了

相关推荐
IT规划师1 天前
Redis 数据类型全解 - List:用对是队列用错是灾难(二)
redis·消息队列·.net
1-1=01 天前
.NET Core 编译技术
.net·.netcore
1-1=02 天前
.NET Core 文件系统
.net·.netcore·1024程序员节
IsITGirl2 天前
VMware Fusion(Mac)Windows ARM 虚拟机 NAT (vmnet8) 报错解决记录
windows·macos·.net·桥接模式
学以智用3 天前
WinForms / WPF / Blazor 项目模板详解
.net
1-1=03 天前
.NET Core 内存管理
.net·.netcore
无风听海3 天前
.NET 10之Span技术总结
.net
1-1=03 天前
.NET Core 配置与选项
.net·.netcore·1024程序员节