Ando Operations

Globals and helpers available in all build.ando scripts.

Globals

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

Operation Description
DotnetProject
Creates a reference to a .NET project file (.csproj). Used with Dotnet and Ef operations.
Directory
Creates a reference to a directory. Used with Npm and Cloudflare operations. Supports path combining with the / operator.
Root
The root path of the project (where build.ando is located). Supports path combining with the / operator.
Context
Provides access to build context including paths and variables. Use Context.Paths for path helpers and Context.Vars for build variables.
Options
Build options for configuring the workflow. Set configuration, Docker image, and other build-wide settings.
Configuration
Enum for build configuration. Returns the current configuration set via Options.UseConfiguration().
Artifacts
Operations for copying build artifacts from the container to the host after the build completes.
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.

Reference Types

ANDO uses typed references for projects and directories, providing compile-time safety and clear intent.

DotnetProject

Creates a reference to a .NET project file. Used with Dotnet and Ef operations.

var app = DotnetProject("./src/MyApp/MyApp.csproj");
Dotnet.Build(app);

Directory

Creates a reference to a directory. Used with Npm and Cloudflare operations. Supports the / operator for path combining.

var frontend = Directory("./frontend");
Npm.Ci(frontend);
Npm.Build(frontend);

// Use / operator to specify subdirectories for deployment
Cloudflare.PagesDeploy(frontend / "dist", "my-site");

Path Helpers

ANDO provides path helpers that support the / operator for readable path construction.

// Root is the project root (where build.ando is located)
var output = Root / "dist";
var artifacts = Root / "artifacts" / "release";

// Context.Paths provides additional path helpers
var artifactsDir = Context.Paths.Artifacts;

Dotnet.Publish(app, o => o.Output(output));

Build Variables

Use Context.Vars to store and retrieve build variables, including environment variables.

// Set custom variables
Context.Vars["BUILD_NUMBER"] = "123";

// Read environment variables (returns null if not set)
var apiKey = Context.Vars.Env("API_KEY");

// Require an environment variable (throws if not set)
var dbUrl = Context.Vars.EnvRequired("DATABASE_URL");

Build Options

The Options global provides methods to configure build behavior. These settings affect subsequent operations in the build script.

Method Description
UseConfiguration(config) Sets the build configuration (Debug or Release). Affects Dotnet.Build, Dotnet.Test, and Dotnet.Publish operations.
UseImage(image) Sets the Docker image for the build container. Overrides the CLI default (e.g., "ubuntu:22.04", "node:20").

Configuration Enum

The Configuration global provides the available build configurations.

Value Description
Configuration.Debug Debug configuration with debugging symbols. This is the default.
Configuration.Release Release configuration with optimizations enabled.

Example Usage

// Set release configuration for optimized builds
Options.UseConfiguration(Configuration.Release);

// Use a specific Docker image
Options.UseImage("mcr.microsoft.com/dotnet/sdk:9.0");

// Chain multiple options
Options
    .UseConfiguration(Configuration.Release)
    .UseImage("ubuntu:24.04");

// Now all Dotnet operations use Release configuration
Dotnet.Build(app);  // Uses -c Release

Complete Example

A full-stack build script showing all the core globals in action.

build.ando
// Project and directory references
var api = DotnetProject("./src/Api/Api.csproj");
var frontend = Directory("./frontend");

// Configure build options
Options.UseConfiguration(Configuration.Release);

// Build backend
Dotnet.Restore(api);
Dotnet.Build(api);
Dotnet.Publish(api, o => o.Output(Root / "dist" / "api"));

// Build frontend
Npm.Ci(frontend);
Npm.Build(frontend);

// Copy artifacts to host
Artifacts.CopyToHost("dist", "./dist");