Build x64 and ARM64 assembly with dotnet build.

AsmSdk turns assembly into shared libraries, static libraries and programs for Windows, Linux and macOS, shares them as versioned NuGet packages, and keeps them in the same solution as your C#, which gets the build of the platform it runs on. The assemblers and linkers come with it.

The AsmFoundation A, each block labelled with a machine-code byte from the samples 8D 04 37 C3 31 C0 48 85 F6 7E 0F 4C 63
The mint blocks are hello_add, assembled for Linux and macOS: lea eax, [rdi + rsi] is 8D 04 37 and ret is C3. The teal blocks are the first bytes of sum_i32. Both functions come from the samples on this site.

Three files to a shared library

  1. Name the SDK in global.json

    { "msbuild-sdks": {
        "AsmFoundation.Sdk": "0.3.0" } }
  2. Add Hello/Hello.asmproj

    <Project Sdk="AsmFoundation.Sdk">
      <PropertyGroup>
        <AssemblyName>hello</AssemblyName>
        <RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
      </PropertyGroup>
    </Project>
  3. Run dotnet build

    Hello -> bin/Debug/freestanding/win-x64/hello.dll
    Hello -> bin/Debug/freestanding/linux-x64/libhello.so
    Hello -> bin/Debug/freestanding/osx-x64/libhello.dylib

    Every *.asm next to the project is assembled for each x64 platform, the way every *.cs is compiled in a .csproj. A *.s file adds ARM64. Walk through it.

What a build does

The ecosystem

KvAsm
A gRPC key-value server in assembly. Its unmodified source builds with AsmSdk.
GrpcAsm
A gRPC server and client in assembly, built with AsmSdk: its NASM, C and .NET APIs work today, Python is next (in development).
asmsdk for Claude Code
A plugin that teaches Claude Code the SDK, with a scaffolder, a linter and an ELF inspector.

The toolchain

NASM 3.02
Assembles the x64 sources. The official binary on Windows, built from source on Linux and macOS.
llvm-mc 23.1.5
Assembles the GNU-syntax sources: ARM64.
lld 23.1.5
Links for Windows, Linux and macOS: lld-link, ld.lld and ld64.lld in one program.
llvm-ar, llvm-readobj
Write deterministic archives and inspect what came out.