Operations
| Operation | Description |
|---|---|
Dotnet.SdkInstall | Install .NET SDK globally in the container. Skips installation if already present (for warm containers). Use when building on base images like Ubuntu that don't have .NET pre-installed. |
Dotnet.Project | Creates a reference to a .NET project file (.csproj). Used with Dotnet and Ef operations. |
Dotnet.Restore | Restore NuGet packages for a project. |
Dotnet.Build | Compile a project with optional configuration. |
Dotnet.Test | Run unit tests for a project. |
Dotnet.Publish | Create deployment artifacts with full publish options. |
Dotnet.Tool | Create a reference to a .NET CLI tool for installation. |
Operation Details
Dotnet.SdkInstall
Install .NET SDK globally in the container. Skips installation if already present (for warm containers). Use when building on base images like Ubuntu that don't have .NET pre-installed.
Dotnet.SdkInstall(); // Installs .NET SDK 9.0
Dotnet.SdkInstall("8.0"); // Installs .NET SDK 8.0Dotnet.Project
Creates a reference to a .NET project file (.csproj). Used with Dotnet and Ef operations.
var app = Dotnet.Project("./src/MyApp/MyApp.csproj");
Dotnet.Build(app);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.csando
// 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());