This devcontainer is configured to provide you a DotNet SDK 8.0 and wasi-sdk 20.0.
-
Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.
-
Install the WASI workload:
dotnet workload install wasi-experimental
- Generate WASI-enabled .Net project:
dotnet new wasiconsole -o HTTPRequestingPlugin
cd
into that project's directory:
cd HTTPRequestingPlugin
- Add Extism PDK dependency to project:
dotnet add package Extism.Pdk --prerelease
- Patch project configuration to produce solid standalone WASM file ( info ):
sed -si.bak 's|<PublishTrimmed>true</PublishTrimmed>|& \n\n<WasmSingleFileBundle>true</WasmSingleFileBundle>\n<WasmBuildNative>true</WasmBuildNative>\n|' HTTPRequestingPlugin.csproj
- Copy HTTP example source code into project's folder to replace generated one:
cp ../Program.cs .
- Compile the example:
dotnet build
Build process creates 25M-sized HTTPRequestingPlugin/bin/Debug/net8.0/wasi-wasm/AppBundle/HTTPRequestingPlugin.wasm
bundle.
For testing purposes, you can invoke functions from Extism plugins with Extism CLI.
- Install
Extism CLI
from Github releases:
wget https://github.com/extism/cli/releases/download/v0.3.0/extism-v0.3.0-linux-amd64.tar.gz
tar -xzf extism-v0.3.0-linux-amd64.tar.gz
And now you have extism
binary in current folder.
- Run default function (it's
_start
) from extism plugin with CLI, allowing outbound connections to all hosts:
./extism call ./bin/Debug/net8.0/wasi-wasm/AppBundle/HTTPRequestingPlugin.wasm _start --allow-host '*' --wasi
Perform your own experiments if desired.
This devcontainer is based on dev-wasm/dev-wasm-dotnet.
Created for (wannabe-awesome) list