Ando Operations

Globals and helpers available in all build.csando scripts.

Globals

These globals are available in all build.csando scripts without any prefix or import.

Operation Description
Root
The root path of the project (where build.csando is located). Supports path combining with the / operator.
Temp
Temporary files directory (root/.ando/tmp). Supports path combining with the / operator. Use for caches, intermediate files, etc.
Env
Gets an environment variable. By default throws if not set. Pass required: false to return null instead.
Directory
Creates a reference to a directory. Used with Npm and Cloudflare operations. Supports path combining with the / operator.
// Directory reference
var frontend = Directory("./frontend");

// Path construction with / operator
var output = Root / "dist";
var cache = Temp / "build-cache";

// Access environment variables
var dbUrl = Env("DATABASE_URL");
var apiKey = Env("API_KEY", required: false);

// Use regular C# variables for custom values
var buildNumber = "123";

Log

Logging operations for outputting messages during the build. Visibility depends on verbosity level.

Operation Description
Log.Info
Logs an informational message. Visible at Normal and Detailed verbosity levels.
Log.Warning
Logs a warning message. Visible at Minimal, Normal, and Detailed verbosity levels.
Log.Error
Logs an error message. Always visible regardless of verbosity level.
Log.Debug
Logs a debug message. Only visible at Detailed verbosity level.
// Informational messages (visible at Normal verbosity)
Log.Info("Starting build process...");

// Warnings (visible at Minimal verbosity and above)
Log.Warning("Cache directory not found, rebuilding from scratch");

// Errors (always visible)
Log.Error("Build failed: missing dependency");

// Debug messages (only visible at Detailed verbosity)
Log.Debug($"Processing file: {filePath}");

Ando

Build configuration, artifact copying, and nested builds. Use these to set the Docker image, copy outputs to host, and run child build scripts.

Operation Description
Ando.UseImage
Set the Docker image for the current build container. Must be called before build steps execute.
Ando.CopyArtifactsToHost
Register files to copy from the container to the host after the build completes. The first parameter is the path inside the container (relative to /workspace or absolute), and the second is the destination on the host (relative to project root or absolute).
Ando.CopyZippedArtifactsToHost
Register files to be archived and copied from the container to the host after the build completes. Creates a single archive file for faster transfer of many small files. Supports .tar.gz (default) and .zip formats. If the destination is a directory, creates artifacts.tar.gz in that directory.
Ando.Build
Run a nested build script. Accepts a directory (runs build.csando in that directory) or a specific .csando file path. The child build runs in its own isolated container with its own .env file and context.
// Set the Docker image for the build container
Ando.UseImage("mcr.microsoft.com/dotnet/sdk:9.0");

// Copy artifacts from container to host after build
Ando.CopyArtifactsToHost("dist", "./dist");

// Copy as compressed archive (faster for many small files)
Ando.CopyZippedArtifactsToHost("dist", "./output");  // Creates ./output/artifacts.tar.gz
Ando.CopyZippedArtifactsToHost("dist", "./dist/binaries.tar.gz");  // Specific filename
Ando.CopyZippedArtifactsToHost("dist", "./dist/binaries.zip");     // Zip format

// Run a child build in a subdirectory
Ando.Build(Directory("./website"));

// Run a specific build file
Ando.Build(Directory("./website") / "deploy.csando");

// Child build with Docker-in-Docker enabled
Ando.Build(Directory("./integration-tests"), o => o.WithDind());