Location>code7788 >text

Note a pitfall during cross-compilation of .NET AOT

Popularity:25 ℃/2025-04-02 16:20:25

Note a pitfall during cross-compilation of .NET AOT

background:

Avalonia projects developed using .NET9 need to be deployed to Linux-arm64

Touching the pit:

According to the officialAOT cross-compilation documentAfter configuration, execute package

dotnet publish -r linux-arm64

hinterror : The PrivateSdkAssemblies ItemGroup is required for _ComputeAssembliesToCompileToNative

Find the answer:

By searching on Github, I found aAOT cross-compiled documentation

This document points out that if you need to cross-compile to the corresponding compiler, you need the corresponding ILCompiler package. If you need to cross-compile to Linux-arm64, you need toBag

solve:

Add toExecute NUGET packagedotnet publish -r linux-arm64, the compilation is successful

Follow-up:

Delete after compilation is successfulPackage reference, and cross-compilation is performed again, it seems that it can succeed. It may be just that this package needs to download the corresponding ILCompiler back, so there is no need to refer to it in the future.