EXPERIMENTAL
-
MSBuild task is an unit of execution inside a build, that can be created by users of MSBuild
-
experimental project exporing using Wasm/WASI to create MSBuild tasks
-
Wasm/WASI supports multiple languages extending the notion of a MSBuild Task from a C# class to a Wasm module
- Rust example tasks [examples/]
-
The tasks run in a Wasm/WASI runtime - Wasmtime which sandboxes the execution from the rest of the system and files/directories a task allowed to touch have to be specified.
-
see spec for details
-
State: Proof of concept, will not be maintained, outcome is that the WASI ecosystem is not ready for productization in MSBuild (Aug 2024)
-
Released as NuGet packages: MSBuildWasm, MSBuildWasm.Templates
Create a MSBuild task using Wasm/WASI toolchain.
- install wasi-sdk, cargo, build the .dll for MSBuildWasm (e.g. by
dotnet publish src
) - copy rust_template from the examples folder and add your behavior to the
lib.rs
file, take care to specify the input/output parameters - compile with
cargo build --release --target wasm32-wasi
- in your project's
project.csproj
that you want to build with MSBuild include the task
<UsingTask TaskName="MyWasmTask" AssemblyFile="MSBuildWasm.dll" TaskFactory="WasmTaskFactory">
<Task>your_module.wasm</Task>
</UsingTask>
- use the task in a target
<Target Name="MyWasmTarget" AfterTargets="Build">
<MyWasmTask Param="StringParam" Param2="true">
<Output TaskParameter="Result" PropertyName="TaskResult"/>
</MyWasmTask>
</Target>
dotnet build
the spec elaborates how this package interplays with MSBuild and how to create a task
see .github/workflows/dotnet.yml
action
- compile examples and template rust tasks to using
cargo
dotnet test test/WasmTasksTests
This project is licensed under the MIT License - see the LICENSE file for details.
This project includes software developed under the Apache License, Version 2.0: Wasmtime - https://github.com/bytecodealliance/wasmtime Wasmtime.Dotnet - https://github.com/bytecodealliance/wasmtime-dotnet
For full terms and conditions, please see the Apache 2.0 license.