Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ env:
REGISTRY: ghcr.io
GO_VERSION: 1.26.5
TINYGO_VERSION: 0.41.1
DOTNET_VERSION: 10.0.112

jobs:
build:
Expand All @@ -37,6 +38,9 @@ jobs:
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- uses: acifani/setup-tinygo@f51bf108c9895381060398804ce6cf6f62692106 # v3.0.1
with:
tinygo-version: ${{ env.TINYGO_VERSION }}
Expand Down Expand Up @@ -93,6 +97,24 @@ jobs:
file: brave-search-rs.wasm
- name: get-open-meteo-weather-js
file: get-open-meteo-weather-js.wasm
- name: eval-dotnet
file: eval-dotnet.wasm
- name: fetch-dotnet
file: fetch-dotnet.wasm
- name: filesystem-dotnet
file: filesystem-dotnet.wasm
- name: get-open-meteo-weather-dotnet
file: get-open-meteo-weather-dotnet.wasm
- name: get-weather-dotnet
file: get-weather-dotnet.wasm
- name: github-dotnet
file: github-dotnet.wasm
- name: gomodule-dotnet
file: gomodule-dotnet.wasm
- name: memory-dotnet
file: memory-dotnet.wasm
- name: time-server-dotnet
file: time-server-dotnet.wasm
steps:
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/validate-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ on:
branches: [ "main" ]
paths:
- 'component-registry.json'
workflow_run:
workflows: [ "Publish Examples" ]
types: [ completed ]

env:
CARGO_TERM_COLOR: always

jobs:
validate:
if: |
github.event_name == 'pull_request' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main')
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -19,6 +26,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # Fetch all history to compare with main branch
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
Expand All @@ -41,6 +49,8 @@ jobs:
run: just build release

- name: Validate component registry
env:
VALIDATE_REMOTE_COMPONENTS: ${{ github.event_name == 'workflow_run' }}
run: ./scripts/validate-component-registry.sh

- name: Summary
Expand Down
94 changes: 94 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,108 @@ ensure-wit-docs-inject:
echo "wit-docs-inject is already installed"
fi

# Require the .NET 10 SDK used by componentize-dotnet examples.
ensure-dotnet:
#!/usr/bin/env bash
set -euo pipefail
version="$(dotnet --version)"
expected="${DOTNET_VERSION:-10.0.112}"
if [[ "$version" != "$expected" ]]; then
echo "error: .NET SDK $expected is required (found $version)" >&2
exit 1
fi

# Inject docs into a wasm component
inject-docs wasm_path wit_dir:
@echo "Injecting docs into {{ wasm_path }}"
wit-docs-inject --component {{ wasm_path }} --wit-dir {{ wit_dir }} --inplace

build-time-server-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/time-server-dotnet && just build)
wasm-tools validate examples/time-server-dotnet/bin/Release/net10.0/wasi-wasm/native/time-server-dotnet.wasm
wasm-tools component wit examples/time-server-dotnet/bin/Release/net10.0/wasi-wasm/native/time-server-dotnet.wasm > /dev/null
just inject-docs examples/time-server-dotnet/bin/Release/net10.0/wasi-wasm/native/time-server-dotnet.wasm examples/time-server-dotnet/wit
wasm-tools validate examples/time-server-dotnet/bin/Release/net10.0/wasi-wasm/native/time-server-dotnet.wasm
cp examples/time-server-dotnet/bin/Release/net10.0/wasi-wasm/native/time-server-dotnet.wasm bin/time-server-dotnet.wasm

build-fetch-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/fetch-dotnet && just build)
wasm-tools validate examples/fetch-dotnet/bin/Release/net10.0/wasi-wasm/native/fetch-dotnet.wasm
wasm-tools component wit examples/fetch-dotnet/bin/Release/net10.0/wasi-wasm/native/fetch-dotnet.wasm > /dev/null
just inject-docs examples/fetch-dotnet/bin/Release/net10.0/wasi-wasm/native/fetch-dotnet.wasm examples/fetch-dotnet/wit
wasm-tools validate examples/fetch-dotnet/bin/Release/net10.0/wasi-wasm/native/fetch-dotnet.wasm
cp examples/fetch-dotnet/bin/Release/net10.0/wasi-wasm/native/fetch-dotnet.wasm bin/fetch-dotnet.wasm

build-filesystem-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/filesystem-dotnet && just build)
just inject-docs examples/filesystem-dotnet/bin/Release/net10.0/wasi-wasm/native/filesystem-dotnet.wasm examples/filesystem-dotnet/wit
wasm-tools validate examples/filesystem-dotnet/bin/Release/net10.0/wasi-wasm/native/filesystem-dotnet.wasm
wasm-tools component wit examples/filesystem-dotnet/bin/Release/net10.0/wasi-wasm/native/filesystem-dotnet.wasm > /dev/null
cp examples/filesystem-dotnet/bin/Release/net10.0/wasi-wasm/native/filesystem-dotnet.wasm bin/filesystem-dotnet.wasm

build-get-weather-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/get-weather-dotnet && just build)
just inject-docs examples/get-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-weather-dotnet.wasm examples/get-weather-dotnet/wit
wasm-tools validate examples/get-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-weather-dotnet.wasm
wasm-tools component wit examples/get-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-weather-dotnet.wasm > /dev/null
cp examples/get-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-weather-dotnet.wasm bin/get-weather-dotnet.wasm

build-get-open-meteo-weather-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/get-open-meteo-weather-dotnet && just build)
just inject-docs examples/get-open-meteo-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-open-meteo-weather-dotnet.wasm examples/get-open-meteo-weather-dotnet/wit
wasm-tools validate examples/get-open-meteo-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-open-meteo-weather-dotnet.wasm
wasm-tools component wit examples/get-open-meteo-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-open-meteo-weather-dotnet.wasm > /dev/null
cp examples/get-open-meteo-weather-dotnet/bin/Release/net10.0/wasi-wasm/native/get-open-meteo-weather-dotnet.wasm bin/get-open-meteo-weather-dotnet.wasm

build-eval-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/eval-dotnet && just build)
just inject-docs examples/eval-dotnet/bin/Release/net10.0/wasi-wasm/native/eval-dotnet.wasm examples/eval-dotnet/wit
wasm-tools validate examples/eval-dotnet/bin/Release/net10.0/wasi-wasm/native/eval-dotnet.wasm
wasm-tools component wit examples/eval-dotnet/bin/Release/net10.0/wasi-wasm/native/eval-dotnet.wasm > /dev/null
cp examples/eval-dotnet/bin/Release/net10.0/wasi-wasm/native/eval-dotnet.wasm bin/eval-dotnet.wasm

build-memory-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/memory-dotnet && just build)
just inject-docs examples/memory-dotnet/bin/Release/net10.0/wasi-wasm/native/memory-dotnet.wasm examples/memory-dotnet/wit
wasm-tools validate examples/memory-dotnet/bin/Release/net10.0/wasi-wasm/native/memory-dotnet.wasm
wasm-tools component wit examples/memory-dotnet/bin/Release/net10.0/wasi-wasm/native/memory-dotnet.wasm > /dev/null
cp examples/memory-dotnet/bin/Release/net10.0/wasi-wasm/native/memory-dotnet.wasm bin/memory-dotnet.wasm

build-github-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/github-dotnet && just build)
just inject-docs examples/github-dotnet/bin/Release/net10.0/wasi-wasm/native/github-dotnet.wasm examples/github-dotnet/wit
wasm-tools validate examples/github-dotnet/bin/Release/net10.0/wasi-wasm/native/github-dotnet.wasm
wasm-tools component wit examples/github-dotnet/bin/Release/net10.0/wasi-wasm/native/github-dotnet.wasm > /dev/null
cp examples/github-dotnet/bin/Release/net10.0/wasi-wasm/native/github-dotnet.wasm bin/github-dotnet.wasm

build-gomodule-dotnet: ensure-dotnet ensure-wit-docs-inject
mkdir -p bin
(cd examples/gomodule-dotnet && just build)
just inject-docs examples/gomodule-dotnet/bin/Release/net10.0/wasi-wasm/native/gomodule-dotnet.wasm examples/gomodule-dotnet/wit
wasm-tools validate examples/gomodule-dotnet/bin/Release/net10.0/wasi-wasm/native/gomodule-dotnet.wasm
wasm-tools component wit examples/gomodule-dotnet/bin/Release/net10.0/wasi-wasm/native/gomodule-dotnet.wasm > /dev/null
cp examples/gomodule-dotnet/bin/Release/net10.0/wasi-wasm/native/gomodule-dotnet.wasm bin/gomodule-dotnet.wasm

build-examples mode="debug":
mkdir -p bin
just ensure-wit-docs-inject
just build-time-server-dotnet
just build-fetch-dotnet
just build-filesystem-dotnet
just build-get-weather-dotnet
just build-get-open-meteo-weather-dotnet
just build-eval-dotnet
just build-memory-dotnet
just build-github-dotnet
just build-gomodule-dotnet
(cd examples/fetch-rs && just build {{ mode }})
(cd examples/filesystem-rs && just build {{ mode }})
(cd examples/get-weather-js && just build)
Expand Down
45 changes: 45 additions & 0 deletions component-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,31 @@
"description": "A knowledge graph memory storage component written in JavaScript",
"uri": "oci://ghcr.io/microsoft/memory-js:latest"
},
{
"name": "Memory Server (.NET)",
"description": "An in-memory knowledge graph component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/memory-dotnet:latest"
},
{
"name": "Weather Server",
"description": "A weather component written in JavaScript",
"uri": "oci://ghcr.io/microsoft/get-weather-js:latest"
},
{
"name": "Weather Server (.NET)",
"description": "An OpenWeather component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/get-weather-dotnet:latest"
},
{
"name": "Open-Meteo Weather",
"description": "A weather component using Open-Meteo API written in JavaScript",
"uri": "oci://ghcr.io/microsoft/get-open-meteo-weather-js:latest"
},
{
"name": "Open-Meteo Weather (.NET)",
"description": "An Open-Meteo weather component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/get-open-meteo-weather-dotnet:latest"
},
{
"name": "Time Server",
"description": "A time server component written in JavaScript",
Expand All @@ -34,16 +49,31 @@
"description": "A Python expression evaluation component",
"uri": "oci://ghcr.io/microsoft/eval-py:latest"
},
{
"name": "Expression Evaluation (.NET)",
"description": "A NativeAOT-safe expression evaluation component using .NET 10",
"uri": "oci://ghcr.io/microsoft/eval-dotnet:latest"
},
{
"name": "Fetch",
"description": "A fetch component written in Rust",
"uri": "oci://ghcr.io/microsoft/fetch-rs:latest"
},
{
"name": "Fetch (.NET)",
"description": "A WASI HTTP fetch component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/fetch-dotnet:latest"
},
{
"name": "Filesystem",
"description": "A filesystem component written in Rust",
"uri": "oci://ghcr.io/microsoft/filesystem-rs:latest"
},
{
"name": "Filesystem (.NET)",
"description": "A policy-controlled filesystem component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/filesystem-dotnet:latest"
},
{
"name": "Brave Search",
"description": "A web search component using Brave Search API written in Rust",
Expand All @@ -53,5 +83,20 @@
"name": "Go Module Information",
"description": "A Go module component",
"uri": "oci://ghcr.io/microsoft/gomodule-go:latest"
},
{
"name": "GitHub API (.NET)",
"description": "A read-only GitHub REST subset using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/github-dotnet:latest"
},
{
"name": "Go Module Information (.NET)",
"description": "A Go module proxy component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/gomodule-dotnet:latest"
},
{
"name": "Time Server (.NET)",
"description": "A WASI wall-clock component using .NET 10 NativeAOT",
"uri": "oci://ghcr.io/microsoft/time-server-dotnet:latest"
}
]
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- [Python](./cookbook/python.md)
- [Rust](./cookbook/rust.md)
- [Go](./cookbook/go.md)
- [.NET](./cookbook/dotnet.md)
- [Publishing to OCI Registries](./cookbook/publishing-to-oci-registries.md)

# Reference
Expand Down
11 changes: 11 additions & 0 deletions docs/cookbook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ Develop Wasm components using Go and TinyGo. Great for developers who prefer Go'
- Growing WebAssembly support
- Examples: module information service

### [.NET](./dotnet.md)
Build NativeAOT-safe WASI components with C# and .NET 10 using
`componentize-dotnet`.

**Key highlights:**
- Traditional `.csproj` projects with explicit WIT world selection
- Generated C# bindings for WIT exports and WASI imports
- NativeAOT and policy-aware capability access
- Examples: time, weather, HTTP, filesystem, GitHub, Go modules, evaluation,
and in-memory tools

## Distribution and Deployment

### [Publishing to OCI Registries](./publishing-to-oci-registries.md)
Expand Down
Loading
Loading