-
Notifications
You must be signed in to change notification settings - Fork 0
Reference | Engine
XakeEngine provides a long-lived build engine for scenarios like watch mode or editor integrations. Unlike xakeScript which runs to completion, an engine stays alive and accepts on-demand build requests.
Use the start operation inside xakeEngine:
let engine = xakeEngine {
rules [
command "build" {
do! sh "dotnet build src/core" {}
}
command "test" {
do! sh "dotnet test src/tests" {}
}
]
start
}Or start from an assembled XakeScript:
let engine = XakeEngine.Start(XakeScript(options, rules))
xakeEnginehasIgnoreCommandLine = true,NoPersist = true, and silent logging by default.
Call Demand to build a target. It returns a Task:
do! engine.Demand("build") |> Async.AwaitTask
do! engine.Demand("test") |> Async.AwaitTaskPass extra variables per demand:
do! engine.Demand("build", vars = ["Config", "Release"]) |> Async.AwaitTaskConcurrent demands for the same target are serialized — if a build is already in flight, subsequent callers wait for it to finish and then re-evaluate.
StopAsync waits for in-flight tasks to complete, runs any teardown targets, then releases resources:
do! engine.StopAsync() |> Async.AwaitTaskRegister targets to run during shutdown:
let engine = xakeEngine {
teardown ["cleanup"]
rules [
command "cleanup" {
do! trace Info "Cleaning up..."
}
]
start
}On .NET 5+ and netstandard2.1+, XakeEngine implements IAsyncDisposable:
use engine = xakeEngine {
rules [ ... ]
start
}
// engine.DisposeAsync() calls StopAsync()