Dotnet Operations

Build, test, and publish .NET projects using the dotnet CLI.

Operations

Operation Description
Dotnet.Restore
Restore NuGet packages for a project.
Dotnet.Restore(App);
Dotnet.Restore(App, o => o.NoCache = true);
Dotnet.Build
Compile a project with optional configuration.
Dotnet.Build(App);
Dotnet.Build(App, o => o.Configuration = Configuration.Release);
Dotnet.Test
Run unit tests for a project.
Dotnet.Test(Tests);
Dotnet.Test(Tests, o => o.Filter = "Category=Unit");
Dotnet.Publish
Create deployment artifacts with full publish options.
Dotnet.Publish(App);
Dotnet.Publish(App, o => o
  .Output(Root / "dist")
  .WithConfiguration(Configuration.Release)
  .WithRuntime("linux-x64")
  .AsSelfContained()
  .AsSingleFile());
Dotnet.Tool
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.

build.ando
// Define project references
var App = Project.From("./src/App/App.csproj");
var Tests = Project.From("./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());