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.
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.
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).