Wasmtime 5.0.1
See the version list below for details.
dotnet add package Wasmtime --version 5.0.1
NuGet\Install-Package Wasmtime -Version 5.0.1
<PackageReference Include="Wasmtime" Version="5.0.1" />
paket add Wasmtime --version 5.0.1
#r "nuget: Wasmtime, 5.0.1"
// Install Wasmtime as a Cake Addin
#addin nuget:?package=Wasmtime&version=5.0.1
// Install Wasmtime as a Cake Tool
#tool nuget:?package=Wasmtime&version=5.0.1
<div align="center"> <h1><code>wasmtime-dotnet</code></h1>
<p> <strong>.NET embedding of <a href="https://github.com/bytecodealliance/wasmtime">Wasmtime</a></strong> </p>
<strong>A <a href="https://bytecodealliance.org/">Bytecode Alliance</a> project</strong>
<p> <a href="https://github.com/bytecodealliance/wasmtime-dotnet/actions?query=workflow%3ACI"> <img src="https://github.com/bytecodealliance/wasmtime-dotnet/workflows/CI/badge.svg" alt="CI status"/> </a> <a href="https://www.nuget.org/packages/Wasmtime"> <img src="https://img.shields.io/nuget/v/wasmtime" alt="Latest Version"/> </a> <a href="https://bytecodealliance.github.io/wasmtime-dotnet/"> <img src="https://img.shields.io/badge/docs-main-green" alt="Documentation"/> </a> </p>
</div>
Installation
You can add a package reference with the .NET SDK:
$ dotnet add package wasmtime
Introduction
For this introduction, we'll be using a simple WebAssembly module that imports a hello
function and exports a run
function:
(module
(func $hello (import "" "hello"))
(func (export "run") (call $hello))
)
To use this module from .NET, create a new console project:
$ mkdir wasmintro
$ cd wasmintro
$ dotnet new console
Next, add a reference to the Wasmtime package:
$ dotnet add package wasmtime
Replace the contents of Program.cs
with the following code:
using System;
using Wasmtime;
namespace WasmIntro
{
class Program
{
static void Main(string[] args)
{
using var engine = new Engine();
using var module = Module.FromText(
engine,
"hello",
"(module (func $hello (import \"\" \"hello\")) (func (export \"run\") (call $hello)))"
);
using var linker = new Linker(engine);
using var store = new Store(engine);
linker.Define(
"",
"hello",
Function.FromCallback(store, () => Console.WriteLine("Hello from C#!"))
);
var instance = linker.Instantiate(store, module);
var run = instance.GetAction("run");
run();
}
}
}
An Engine
is created and then a WebAssembly module is loaded from a string in WebAssembly text format.
A Linker
defines a function called hello
that simply prints a hello message.
The module is instantiated and the instance's run
export is invoked.
To run the application, simply use dotnet
:
$ dotnet run
This should print Hello from C#!
.
Contributing
Building
Use dotnet
to build the repository:
$ dotnet build Wasmtime.sln
This will download the latest development snapshot of Wasmtime for your platform.
Testing
Use dotnet
to run the unit tests:
$ dotnet test Wasmtime.sln
Creating the NuGet package
Use dotnet
to create a NuGet package:
$ cd src
$ dotnet pack Wasmtime.sln -c Release /p:Packing=true
This will create a .nupkg
file in src/bin/Release
.
By default, local builds will use a -dev
suffix for the package to differentiate between official packages and development packages.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net6.0
- No dependencies.
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Wasmtime:
Package | Downloads |
---|---|
Opa.Wasm
Call Open Policy Agent (OPA) policies in WASM (Web Assembly) from .NET |
|
DevCycle.SDK.Server.Local
.NET Server Local Bucketing SDK for DevCycle |
|
Deislabs.WAGI
Provides a configuration driven method to add WAGI modules as route endpoints to ASP.Net Core applications using WAGI.WARNING: WAGI is experimental. It is not considered production-grade by its developers, neither is it "supported" software.. |
|
OpaDotNet.Wasm
Open Policy Agent (OPA) WebAssembly dotnet core SDK |
|
DOPA
A .NET API for evaluating OPA policies compiled as WebAssembly modules. |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on Wasmtime:
Repository | Stars |
---|---|
SteveSandersonMS/DotNetIsolator
A library for running isolated .NET runtimes inside .NET
|
|
JasonBock/Rocks
A mocking library based on the Compiler APIs (Roslyn + Mocks)
|
|
bytecodealliance/wasmtime-demos
Historical and dated demos for Wasmtime usage and WASI content
|
Version | Downloads | Last updated |
---|---|---|
19.0.1 | 1,974 | 4/7/2024 |
19.0.0 | 334 | 3/27/2024 |
18.0.0 | 141 | 3/27/2024 |
17.0.0 | 4,919 | 1/26/2024 |
16.0.0 | 2,983 | 1/2/2024 |
15.0.0 | 804 | 11/21/2023 |
14.0.0 | 29,460 | 10/24/2023 |
13.0.0 | 1,779 | 9/22/2023 |
12.0.2 | 207 | 9/21/2023 |
12.0.1 | 177 | 9/21/2023 |
12.0.0 | 2,808 | 8/21/2023 |
11.0.2 | 190 | 9/22/2023 |
11.0.1 | 14,578 | 7/27/2023 |
11.0.0 | 217 | 7/27/2023 |
10.0.2 | 165 | 9/22/2023 |
10.0.1 | 182 | 9/22/2023 |
10.0.0 | 1,140 | 7/5/2023 |
9.0.3 | 626 | 6/2/2023 |
9.0.2 | 1,132 | 5/30/2023 |
9.0.1 | 14,190 | 5/22/2023 |
9.0.0 | 232 | 5/22/2023 |
8.0.1 | 3,393 | 4/27/2023 |
8.0.0 | 633 | 4/21/2023 |
7.0.1 | 277 | 4/27/2023 |
7.0.0 | 969 | 4/1/2023 |
6.0.2 | 299 | 4/27/2023 |
6.0.1 | 1,798 | 3/8/2023 |
6.0.0 | 890 | 2/27/2023 |
5.0.1 | 629 | 3/8/2023 |
5.0.0 | 64,040 | 1/25/2023 |
4.0.1 | 393 | 3/8/2023 |
4.0.0 | 509 | 1/25/2023 |
3.0.0 | 25,762 | 12/8/2022 |
2.0.2 | 890 | 11/10/2022 |
2.0.1 | 637 | 11/9/2022 |
2.0.0 | 448 | 11/9/2022 |
1.0.2 | 504 | 11/11/2022 |
1.0.1 | 476 | 11/9/2022 |
1.0.0 | 2,078 | 9/26/2022 |
0.40.0-preview1 | 2,680 | 8/29/2022 |
0.39.1-preview2 | 2,873 | 8/11/2022 |
0.39.1-preview1 | 196 | 8/10/2022 |
0.39.0-preview1 | 206 | 8/10/2022 |
0.38.1-preview1 | 1,769 | 6/29/2022 |
0.38.0-preview1 | 214 | 6/29/2022 |
0.37.0-preview1 | 903 | 6/14/2022 |
0.36.0-preview1 | 821 | 4/26/2022 |
0.35.2-preview1 | 1,717 | 4/5/2022 |
0.35.1-preview1 | 216 | 4/5/2022 |
0.35.0-preview1 | 491 | 3/9/2022 |
0.34.0-preview1 | 19,080 | 2/11/2022 |
0.33.0-preview2 | 17,693 | 1/25/2022 |
0.33.0-preview1 | 627 | 1/7/2022 |
0.32.1-preview1 | 231 | 1/7/2022 |
0.32.0-preview1 | 516 | 12/18/2021 |
0.31.0-preview1 | 7,768 | 11/1/2021 |
0.30.0-preview1 | 6,702 | 9/17/2021 |
0.29.0-preview1 | 782 | 8/6/2021 |
0.28.0-preview1 | 41,892 | 6/15/2021 |
0.27.0-preview1 | 1,047 | 5/22/2021 |
0.26.1-preview1 | 262 | 5/21/2021 |
0.26.0-preview1 | 727 | 4/20/2021 |
0.25.0-preview1 | 985 | 3/18/2021 |
0.24.0-preview1 | 337 | 3/18/2021 |
0.23.0-preview1 | 522 | 2/19/2021 |
0.22.1-preview1 | 2,206 | 1/19/2021 |
0.22.0-preview1 | 413 | 1/19/2021 |
0.21.0-preview1 | 585 | 1/14/2021 |
0.20.0-preview1 | 1,524 | 11/2/2020 |
0.19.0-preview1 | 1,626 | 7/24/2020 |
0.18.1-preview1 | 924 | 7/1/2020 |
0.18.0-preview1 | 585 | 6/30/2020 |
0.15.0-preview1 | 1,078 | 4/6/2020 |
0.12.0-preview1 | 839 | 2/26/2020 |
0.8.0-preview2 | 665 | 12/5/2019 |
0.8.0-preview1 | 514 | 11/23/2019 |
0.0.1-alpha1 | 525 | 10/2/2019 |
Update Wasmtime to 5.0.1.