Skip to content

baronfel/MSBuildWasm

 
 

Repository files navigation

Wasm/WASI for MSBuild

  • 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

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>
  1. use the task in a target
<Target Name="MyWasmTarget" AfterTargets="Build">
  <MyWasmTask Param="StringParam" Param2="true">
      <Output TaskParameter="Result" PropertyName="TaskResult"/>
  </MyWasmTask>
</Target>
  1. dotnet build

Inputs and outputs from a tasks can be bools, strings and "ITaskItem" which is basically a file path.

Writing tasks for MSBuild

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%