Skip to content

NuGet package to help you cross-compile Native AOT to different OSes/architectures

License

Notifications You must be signed in to change notification settings

hez2010/PublishAotCross

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PublishAotCross

This is a NuGet package with an MSBuild target to aid in crosscompilation with PublishAot. It helps resolving following error:

$ dotnet publish -r linux-x64
Microsoft.NETCore.Native.Publish.targets(59,5): error : Cross-OS native compilation is not supported.

This NuGet package allows using Zig as the linker/sysroot to allow crosscompiling to linux-x64/linux-arm64/linux-musl-x64/linux-musl-arm64 from a Windows machine.

By default it relies on Zig provided by the unofficial Vezel.Zig.Toolsets NuGet package. You can specify version of this package using the ZigVersion property. Instructions for using your own Zig binaries are near the end of this document.

  1. Optional: download LLVM. We only need llvm-objcopy executable so if you care about size, you can delete the rest. The executable needs to be on PATH. This step is optional and is required only to strip symbols (make the produced executables smaller). If you don't care about stripping symbols, you can skip it.

  2. To your project that is already using Native AOT, add a reference to this NuGet package.

  3. Publish for one of the newly available RIDs:

    • dotnet publish -r linux-x64
    • dotnet publish -r linux-arm64
    • dotnet publish -r linux-musl-x64
    • dotnet publish -r linux-musl-arm64

    If you skipped the second optional step to download llvm-objcopy, you must also pass /p:StripSymbols=false to the publish command, or you'll see an error instructing you to do that.

If you don't want to use Zig from the Vezel.Zig.Toolsets NuGet package, you can specify /p:UseExternalZig=true. This will use whatever Zig is on your PATH. Download an archive with Zig for your host machine, extract it and place it on your PATH.

Even though Zig allows crosscompiling for Windows as well, it's not possible to crosscompile PublishAot like this due to ABI differences (MSVC vs. MingW ABI).

About

NuGet package to help you cross-compile Native AOT to different OSes/architectures

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Batchfile 93.8%
  • C# 6.2%