OpenHarmony.NET.PublishAotCross 0.0.0-alpha.7

This is a prerelease version of OpenHarmony.NET.PublishAotCross.
dotnet add package OpenHarmony.NET.PublishAotCross --version 0.0.0-alpha.7
                    
NuGet\Install-Package OpenHarmony.NET.PublishAotCross -Version 0.0.0-alpha.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenHarmony.NET.PublishAotCross" Version="0.0.0-alpha.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenHarmony.NET.PublishAotCross" Version="0.0.0-alpha.7" />
                    
Directory.Packages.props
<PackageReference Include="OpenHarmony.NET.PublishAotCross" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenHarmony.NET.PublishAotCross --version 0.0.0-alpha.7
                    
#r "nuget: OpenHarmony.NET.PublishAotCross, 0.0.0-alpha.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenHarmony.NET.PublishAotCross@0.0.0-alpha.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenHarmony.NET.PublishAotCross&version=0.0.0-alpha.7&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OpenHarmony.NET.PublishAotCross&version=0.0.0-alpha.7&prerelease
                    
Install as a Cake Tool

OpenHarmony-NET.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.

  1. Download an archive with Zig for your host machine, extract it and place it on your PATH. I'm using zig-windows-x86_64-0.11.0-dev.4006+bf827d0b5.zip.

  2. 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 - you could copy it next to the Zig executable. 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.

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

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

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OpenHarmony.NET.PublishAotCross:

Package Downloads
OpenHarmony.NET.SDK

NativeAot runtime static library and PublishAotCross tools

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.0-alpha.7 258 4/29/2025
0.0.0-alpha.2 599 4/23/2025