Operations
| Operation | Description |
|---|---|
Dotnet.SdkInstall | Install .NET SDK globally in the container. Skips installation if already present (for warm containers). Calling this method disables automatic SDK installation for subsequent operations. Note: Dotnet operations (Build, Test, Restore, Publish) automatically install the SDK if not present. |
Dotnet.Project | Creates a reference to a .NET project file (.csproj). Used with Dotnet and Ef operations. The returned ProjectRef has properties: Path, Name, Directory, and Version (reads from csproj). |
Dotnet.ReadVersion | Evaluated when the script loads, on the host. It is not a step: it does not appear in --dry-run and runs before the container exists. Reads the version from a props file. Signature: string ReadVersion(string path = "Directory.Build.props"), relative to the source root (the --ref worktree when set). The file needs exactly one <Version> directly in a <PropertyGroup>. It reads the literal property: no MSBuild evaluation, imports, conditions or $(...). Throws on a missing file or an empty or ambiguous version. For the version of one project file, use the Version property of Dotnet.Project. |
Dotnet.Restore | Restore NuGet packages for a project. Runs dotnet restore <proj> [--no-cache] [-r <rid>]. Automatically installs .NET SDK if not present. |
Dotnet.Build | Compile a project. Runs dotnet build <proj> [-c <cfg>] [--no-restore] [-p:SourceRevisionId=<sha>] (the property is added automatically with the commit being built, since the container has no .git; nothing outside a git repository; WithSourceRevision(sha) overrides it, WithoutSourceRevision() suppresses it; the global property overrides a project-level SourceRevisionId otherwise). No configuration flag is passed unless you set one, so the .NET default (Debug) applies. Automatically installs .NET SDK if not present. |
Dotnet.Test | Run unit tests for a project. Runs dotnet test <proj> [-c <cfg>] [--no-restore] [--no-build] [--filter <f>]. Automatically installs .NET SDK if not present. |
Dotnet.Publish | Create deployment artifacts. Runs dotnet publish <proj> [-c <cfg>] [-o /workspace/<out>] [--no-restore] [--no-build] [--self-contained | --no-self-contained] [-r <rid>] [-p:PublishSingleFile=true] [--nologo] [-p:SourceRevisionId=<sha>]; the property is added automatically with the commit being built (the container has no .git; nothing outside a git repository) unless WithSourceRevision(sha) is set or SkipBuild() is used; a relative Output("out/web") string resolves against /workspace in the container (-o /workspace/out/web, also with --ref); container-absolute paths and Root / "x" are kept. Release is not the default: pass WithConfiguration(Configuration.Release) for -c Release. Options: Output, WithConfiguration, WithRuntime, AsSelfContained, AsSingleFile, SkipRestore, SkipBuild, WithNoLogo (--nologo). Automatically installs .NET SDK if not present. |
Dotnet.Tool | Create a reference to a .NET CLI tool for installation. |
Operation Details
Dotnet.SdkInstall
source
Install .NET SDK globally in the container. Skips installation if already present (for warm containers). Calling this method disables automatic SDK installation for subsequent operations. Note: Dotnet operations (Build, Test, Restore, Publish) automatically install the SDK if not present.
Dotnet.SdkInstall(); // Installs .NET SDK 9.0
Dotnet.SdkInstall("8.0"); // Installs .NET SDK 8.0Dotnet.Project
source
Creates a reference to a .NET project file (.csproj). Used with Dotnet and Ef operations. The returned ProjectRef has properties: Path, Name, Directory, and Version (reads from csproj).
var app = Dotnet.Project("./src/MyApp/MyApp.csproj");
Dotnet.Build(app);
Log.Info($"Building {app.Name} version {app.Version}");Dotnet.ReadVersion
source
Evaluated when the script loads, on the host. It is not a step: it does not appear in --dry-run and runs before the container exists. Reads the version from a props file. Signature: string ReadVersion(string path = "Directory.Build.props"), relative to the source root (the --ref worktree when set). The file needs exactly one <Version> directly in a <PropertyGroup>. It reads the literal property: no MSBuild evaluation, imports, conditions or $(...). Throws on a missing file or an empty or ambiguous version. For the version of one project file, use the Version property of Dotnet.Project.
var version = Dotnet.ReadVersion();
var version = Dotnet.ReadVersion("src/Directory.Build.props");Dotnet.Restore
source
Restore NuGet packages for a project. Runs dotnet restore <proj> [--no-cache] [-r <rid>]. Automatically installs .NET SDK if not present.
Dotnet.Restore(App);
Dotnet.Restore(App, o => o.NoCache = true);Dotnet.Build
source
Compile a project. Runs dotnet build <proj> [-c <cfg>] [--no-restore] [-p:SourceRevisionId=<sha>] (the property is added automatically with the commit being built, since the container has no .git; nothing outside a git repository; WithSourceRevision(sha) overrides it, WithoutSourceRevision() suppresses it; the global property overrides a project-level SourceRevisionId otherwise). No configuration flag is passed unless you set one, so the .NET default (Debug) applies. Automatically installs .NET SDK if not present.
Dotnet.Build(App);
Dotnet.Build(App, o => o.Configuration = Configuration.Release);Dotnet.Test
source
Run unit tests for a project. Runs dotnet test <proj> [-c <cfg>] [--no-restore] [--no-build] [--filter <f>]. Automatically installs .NET SDK if not present.
Dotnet.Test(Tests);
Dotnet.Test(Tests, o => o.Filter = "Category=Unit");Dotnet.Publish
source
Create deployment artifacts. Runs dotnet publish <proj> [-c <cfg>] [-o /workspace/<out>] [--no-restore] [--no-build] [--self-contained | --no-self-contained] [-r <rid>] [-p:PublishSingleFile=true] [--nologo] [-p:SourceRevisionId=<sha>]; the property is added automatically with the commit being built (the container has no .git; nothing outside a git repository) unless WithSourceRevision(sha) is set or SkipBuild() is used; a relative Output("out/web") string resolves against /workspace in the container (-o /workspace/out/web, also with --ref); container-absolute paths and Root / "x" are kept. Release is not the default: pass WithConfiguration(Configuration.Release) for -c Release. Options: Output, WithConfiguration, WithRuntime, AsSelfContained, AsSingleFile, SkipRestore, SkipBuild, WithNoLogo (--nologo). Automatically installs .NET SDK if not present.
Dotnet.Publish(App);
Dotnet.Publish(App, o => o
.Output(Root / "dist")
.WithConfiguration(Configuration.Release)
.WithRuntime("linux-x64")
.AsSelfContained()
.AsSingleFile());
// Exactly: dotnet publish p -c Release -o out --nologo
Dotnet.Publish(p, o => o.WithConfiguration(Configuration.Release).Output("out").WithNoLogo());Dotnet.Tool
source
Create a reference to a .NET CLI tool for installation.
var efTool = Dotnet.Tool("dotnet-ef");
var efTool = Dotnet.Tool("dotnet-ef", "9.0.0");Example
Build and publish a .NET application.
// Define project references
var App = Dotnet.Project("./src/App/App.csproj");
var Tests = Dotnet.Project("./tests/App.Tests/App.Tests.csproj");
// Restore, build, and test
Dotnet.Restore(App);
Dotnet.Build(App, o => o.Configuration = Configuration.Release);
Dotnet.Test(Tests);
// Publish as self-contained single file
Dotnet.Publish(App, o => o
.Output(Root / "dist")
.WithConfiguration(Configuration.Release)
.WithRuntime("linux-x64")
.AsSelfContained()
.AsSingleFile());
Exact commands
Each operation runs one dotnet command. Parts in brackets are only added when the matching option is set. Nothing is added for the configuration by default, so a build or publish without WithConfiguration uses the .NET default (Debug): Release is not the default.
| Operation | Command |
|---|---|
Dotnet.Restore | dotnet restore <proj> [--no-cache] [-r <rid>] |
Dotnet.Build | dotnet build <proj> [-c <cfg>] [--no-restore] |
Dotnet.Test | dotnet test <proj> [-c <cfg>] [--no-restore] [--no-build] [--filter <f>] |
Dotnet.Publish | dotnet publish <proj> [-c <cfg>] [-o /workspace/<out>] [--no-restore] [--no-build] [--self-contained | --no-self-contained] [-r <rid>] [-p:PublishSingleFile=true] [--nologo] |
A relative Output("out/web") string resolves against /workspace in the build container (normal and --ref runs), so the command gets -o /workspace/out/web and later steps can read the relative out/web. A container-absolute path such as /workspace/out/web and a Root / "web" path are kept. For example, dotnet publish p -c Release -o out --nologo is:
Dotnet.Publish(p, o => o.WithConfiguration(Configuration.Release).Output("out").WithNoLogo());
Reading a version: ReadVersion
Dotnet.ReadVersion(path = "Directory.Build.props") is not a step. It is evaluated when the script loads, on the host, relative to the source root (the --ref worktree when set). The file needs exactly one <Version> directly in a <PropertyGroup>. It reads the literal property: no MSBuild evaluation, imports, conditions or $(...). It throws on a missing file or an empty or ambiguous version. For the version of one project file, use Dotnet.Project(...).Version.
var version = Dotnet.ReadVersion();
Log.Info($"Building {version}");
Options Reference
Dotnet.Restore Options
| Option | Description |
|---|---|
WithRuntime(string) | Set target runtime identifier (e.g., “linux-x64”, “win-x64”, “osx-arm64”). Downloads runtime-specific packages. |
NoCache | Bypass the NuGet cache, forcing fresh downloads of all packages. Useful when debugging package resolution issues. |
Dotnet.Build Options
| Option | Description |
|---|---|
Configuration | Build configuration: Configuration.Debug or Configuration.Release. Debug includes symbols and disables optimizations. Release enables optimizations for production. |
WithSourceRevision(string) | Pass -p:SourceRevisionId=<sha>. ANDO adds the full commit being built automatically (the container has no .git; nothing is added outside a git repository); this overrides it. |
WithoutSourceRevision() | Suppress the automatic -p:SourceRevisionId. Without it, ANDO’s value overrides a <SourceRevisionId> set in the project file. |
NoRestore | Skip the implicit restore before building. Use when you’ve already run Dotnet.Restore() separately. |
Dotnet.Test Options
| Option | Description |
|---|---|
Configuration | Build configuration for running tests. Tests typically run in Debug for better diagnostics. |
NoRestore | Skip restore before testing. Use when dependencies are already restored. |
NoBuild | Skip build before testing. Use when the project is already built. Implies NoRestore. |
Filter | Test filter expression to run specific tests. Examples: "Category=Unit", "FullyQualifiedName~MyNamespace", "Name=MyTest". |
WithSourceRevision(string) | Pass -p:SourceRevisionId=<sha> when the test builds. ANDO adds the full commit being built automatically (nothing outside a git repository) unless NoBuild is set. |
WithoutSourceRevision() | Suppress the automatic -p:SourceRevisionId. Without it, ANDO’s value overrides a <SourceRevisionId> set in the project file. |
Dotnet.Publish Options
| Option | Description |
|---|---|
Output(path) | Output directory for published artifacts. A string is a container path: relative paths resolve against /workspace. A BuildPath is used as given (Root / "dist" is /workspace/dist). |
WithConfiguration(Configuration) | Build configuration. Use Configuration.Release for production deployments. |
WithRuntime(string) | Target runtime identifier. Required for self-contained deployments. Common values: "linux-x64", "linux-arm64", "win-x64", "osx-x64", "osx-arm64". |
AsSelfContained(bool) | Include the .NET runtime with the application. Creates a standalone deployment that doesn’t require .NET to be installed. Defaults to true when called. |
AsSingleFile(bool) | Bundle the entire application into a single executable. Makes deployment simpler but increases startup time slightly. |
SkipRestore() | Skip restore before publishing. Use when dependencies are already restored. |
SkipBuild() | Skip build before publishing. Use when the project is already built. |
WithSourceRevision(string) | Pass -p:SourceRevisionId=<sha>. ANDO adds the full commit being built automatically (nothing outside a git repository) unless this is set or SkipBuild() is used. |
WithoutSourceRevision() | Suppress the automatic -p:SourceRevisionId. Without it, ANDO’s value overrides a <SourceRevisionId> set in the project file. |
WithNoLogo() | Pass --nologo to suppress the startup banner. |