.Net supports more platforms than Microsoft Windows. But people seems to think otherwise. .Net currently supports Windows, Linux and MacOS in x64 and Arm64 platforms. But If you want to run it on other architectures or operating systems there is no way until now.
WASI is a new possible target for .Net 7 compiler. Its experimentally supported as you can see in github. If you want to get your feet wet first install .Net 7 preview from
here you can test it with
dotnet new console -o MyFirstWasiApp cd MyFirstWasiApp dotnet add package Wasi.Sdk --prerelease dotnet build
So how can you run it ? Since its WebAssembly you need a runtime to execute it. Steve Sanders recommends wasmtime which can run in supports Windows, Linux and MacOS in x64 and Arm64 the same environments that .Net natively execute. So what do I get in return ?
People are interested in WebAsssembly and WASI so you might wander what is the hype is all about ? You can consider WebAssembly as a platform agnostic Intermediate Language like in .Net IL. So you can run it with browser and anywhere with a WebAssembly runtime. WASI is a standard which allows WebAssembly to make standardized system calls hence the name WebAssembly System Interface. WASI is a new standard that is currently developed by WebAssembly System Interface Subgroup Charter a subgroup in WebAssembly standard working group.
What all of this means? It means if we have a working WASI runtime for our platform we can run our WebAssembly anywhere. There are a few runtimes available but they are written in way hard to retarget without too much effort except Wazero
GitHub. Wazero is written in Golang with portability in mind. Wazero supports two modes ahead of time compiling when platform is supported or interpreted for every platform it can run.
Wazero is a work in progress expected to release its 1.0 version in Q3 2022 so be warned it misses some specifications. The problem with Wazero is, it do not has a executable to run WebAssembly ( or I could not find it) so I write a simple one. which you can find in https://github.com/bleakview/wasabi/
I use Qemu to emulate environments.
Yes I can run .Net WASI executables on different enviroments, so what are the downsides? When AoT is not supported for the platform, interpreted running is slow and Wazero do not currently supports sockets so no Asp.Net for you.
If .Net 7 release version supports WASI we get the real platform independent executable. Also if WebAssembly began to replace docker .Net will be ready from day one.
As a side note since WASI is a standard I tested it with AssemblyScript WASI files and it works just fine. Technically wasabi can run your programs in the following platforms - platforms supported by Golang as of now- but I do not test them all: