The Zig SDK is an MSBuild SDK that augments the .NET SDK with the ability to build Zig, C, and C++ projects.
With support for multiple programming languages, cross-compilation, NuGet packaging, and more, the Zig SDK makes it trivial to author native components as part of your .NET solution - without all the hassle that is usually part and parcel of building and packaging native code. These features are powered by the Zig toolchain.
Here are some of the Zig SDK highlights:
Multiple programming languages: Although Zig is a modern and pleasant systems programming language, you might prefer to use C or C++ instead. As it happens, the Zig compiler also embds a full C and C++ compiler - namely, Clang. So, whichever language you prefer, the Zig SDK has you covered.
Cross-compilation: Thanks to the Zig compiler's excellent cross-targeting support, cross-compilation is a first-class citizen in the Zig SDK. Gone are the days of having to do overly complicated cross toolchain setup, or resorting to building on multiple platforms for releases - just type dotnet build
to compile for all targets supported by your project.
Unit testing: The Zig language provides built-in unit testing constructs. The Zig SDK allows you to run your project's unit tests with the familiar dotnet test
command. Test name filters are supported - e.g. dotnet test --filter foo
.
Code change monitoring: The Zig SDK integrates with dotnet watch
so that e.g. dotnet watch build
, dotnet watch run
, and dotnet watch test
work as expected, enabling a rapid development loop.
Sensible NuGet packaging: Out of the box, dotnet pack
with the Zig SDK will produce NuGet packages containing cross-built binaries for all platforms that your project supports. Also, your public C and C++ header files will be bundled, as will your Zig source code. This makes the resulting NuGet package easy to consume both in .NET projects and in other projects using the Zig SDK.
Multi-project solutions: Soon™.
Please note that the Zig SDK is not intended to be a full replacement for the Zig Build System. The goal of the Zig SDK is specifically to make it simple to integrate Zig, C, and C++ components into the .NET ecosystem. For that reason, the Zig SDK has no support for platforms that Zig supports but that .NET does not (yet) run on, such as linux-riscv64
. The level of configuration that is possible for C and C++ is also somewhat limited compared to most build systems that support those languages.