Dagger.SDK 0.1.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Dagger.SDK --version 0.1.0
                    
NuGet\Install-Package Dagger.SDK -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dagger.SDK" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dagger.SDK" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Dagger.SDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dagger.SDK --version 0.1.0
                    
#r "nuget: Dagger.SDK, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dagger.SDK@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dagger.SDK&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Dagger.SDK&version=0.1.0
                    
Install as a Cake Tool

Dagger C# SDK

Warning This SDK is experimental. Please do not use it for anything mission-critical. Possible issues include:

  • Missing features
  • Stability issues
  • Performance issues
  • Lack of polish
  • Upcoming breaking changes
  • Incomplete or out-of-date documentation

A client package for running Dagger pipelines in C# / .NET.

What is the Dagger C# SDK?

The Dagger C# SDK provides two distinct but complementary ways to work with Dagger:

1. 🔧 Module Runtime (Source-based Distribution)

Create reusable Dagger modules that can be called by others:

dagger init --sdk=csharp --name=my-module

This generates a module where you write functions decorated with [DaggerObject] and [DaggerFunction]. The SDK source code is generated directly into your module for version consistency.

Use this for: Creating reusable CI/CD functions, building shareable modules, extending Dagger's capabilities

2. 📦 Client Library (NuGet Package)

Use Dagger programmatically in any .NET application:

dotnet add package Dagger.SDK

Import the SDK and call the Dagger API directly to build custom pipelines.

Use this for: Custom CI/CD scripts, build automation, one-off pipeline tasks

Documentation

Requirements

  • .NET 9.0 or later
  • Docker, or another OCI-compatible container runtime
  • Dagger CLI v0.19.0 or later

🔧 Usage as a Module Runtime (Source-based)

How It Works

When you run dagger init --sdk=csharp, the runtime module generates the Dagger SDK code directly in your module:

  1. The SDK source code is generated into your module's sdk/ directory
  2. You write functions decorated with [DaggerObject] and [DaggerFunction]
  3. The Dagger engine loads and executes your module

This source-based approach ensures version consistency and eliminates dependency conflicts.

Example Module

using Dagger.SDK;

[Object]
public class MyModule
{
    /// <summary>
    /// Returns a container that echoes a message
    /// </summary>
    [Function]
    public Container Echo(string message)
    {
        return Dag
            .Container()
            .From("alpine:latest")
            .WithExec(new[] { "echo", message });
    }

    /// <summary>
    /// Builds and tests a Go project
    /// </summary>
    [Function]
    public async Task<string> BuildAndTest(Directory source)
    {
        return await Dag
            .Container()
            .From("golang:1.21")
            .WithMountedDirectory("/src", source)
            .WithWorkdir("/src")
            .WithExec(new[] { "go", "build", "./..." })
            .WithExec(new[] { "go", "test", "./..." })
            .Stdout();
    }
}

📦 Usage as a Client Library (NuGet)


📦 Usage as a Client Library (NuGet)

Installation

Add the Dagger.SDK NuGet package to your project:

dotnet add package Dagger.SDK

Example: Standalone Client

using Dagger.SDK;

// Build a custom pipeline programmatically
var result = await Dag
    .Container()
    .From("alpine:latest")
    .WithExec(new[] { "echo", "Hello from Dagger!" })
    .Stdout();

Console.WriteLine(result);

Running Your Client App

Use dagger run to ensure a Dagger session is available:

dagger run dotnet run

See the standalone-client example for more detailed usage patterns.


Module Runtime Internals

  1. Builds the Dagger SDK with your module's introspection schema

  2. Copies SDK DLLs to your module's sdk/ folder

  3. Initializes your module (if new) with template files:

    • Main.cs - Your module class with Dagger functions
    • Program.cs - Entrypoint that bootstraps the SDK runtime
    • DaggerModule.csproj - Project file referencing the SDK
  4. Execution flow:

    Dagger Engine → dotnet run (Program.cs) → ModuleRuntime (from SDK) → Your module functions
    

The Program.cs is a simple bootstrap:

using Dagger.SDK.Module;
return await ModuleRuntime.RunAsync(args);

The ModuleRuntime (in the SDK) handles:

  • Discovering classes marked with [DaggerObject]
  • Discovering methods marked with [DaggerFunction]
  • Registration (--register flag): Returns module schema
  • Execution: Calls your functions when invoked

Client API

The Dagger client API is generated at build time by the Source Generator from introspection.json. The generated code provides type-safe access to all Dagger API types and methods.

You access the API through the static Dagger.Dag() method (defined in the generated code):

var container = Dagger.Dag()
    .Container()
    .From("alpine:latest")
    .WithExec(new[] { "echo", "hello" });

The Source Generator (Dagger.SDK.CodeGen) reads the GraphQL schema and generates:

  • All Dagger types (Container, Directory, File, etc.)
  • Query methods
  • Type-safe method chaining
  • Proper async/await support

Learn more

Development

The SDK is managed with a Dagger module in ./dev. To see which tasks are available run:

dagger call -m dev

Common tasks

Run tests:

dagger call -m dev test --introspection-json=<path>

Check for linting violations:

dagger call -m dev lint

Re-format code:

dagger call -m dev format export --path=.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated