JanProvaznik / MSBuildWasm

WebAssembly system interface plugins to MSBuild
MIT License
3 stars 2 forks source link

Wasm/WASI tasks for MSBuild

EXPERIMENTAL

User manual

Create a MSBuild task using Wasm/WASI toolchain.

  1. install wasi-sdk, cargo, build the .dll for MSBuildWasm (e.g. by dotnet publish src)
  2. copy rust_template from the examples folder and add your behavior to the lib.rs file, take care to specify the input/output parameters
  3. compile with cargo build --release --target wasm32-wasi
  4. 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>
  5. use the task in a target
    <Target Name="MyWasmTarget" AfterTargets="Build">
    <MyWasmTask Param="StringParam" Param2="true">
      <Output TaskParameter="Result" PropertyName="TaskResult"/>
    </MyWasmTask>
    </Target>
  6. dotnet build

Writing tasks for MSBuild

Developer manual

the spec elaborates how this package interplays with MSBuild and how to create a task

Running tests

see .github/workflows/dotnet.yml action

  1. compile examples and template rust tasks to using cargo
  2. dotnet test test/WasmTasksTests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Third-party Licenses

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.