## Executive Summary

While Aspire originated as a .NET-centric orchestrator for cloud-native microservices, Aspire 17 completes its transformation into a **universal, polyglot, agent-first distributed application toolchain**. In this technical deep-dive, Maddie Montaquila and Jose Perez Rodriguez unveil how Aspire leverages .NET not as a user prerequisite, but as a high-performance **engine and runtime substrate** powering developers across any programming language (TypeScript, Go, Python, Rust, Java).

### Key Architectural Milestones:
1. **The Aspire Type System (ATS):** A cross-language capability dispatch architecture. Rather than transpile languages or maintain disparate backends, Aspire exposes core C# orchestration primitives via `[AspireExport]` metadata, extracted by Roslyn into an ATS contract that generates idiomatic guest language SDKs communicating via bi-directional JSON-RPC.
2. **Solving the Polyglot Callback Problem:** Distributed orchestration requires late-bound callbacks (e.g. `WithEnvironment(context => ...)`). ATS solves this across process boundaries by assigning callback tokens that the .NET backend asynchronously invokes within the guest language runtime (such as Node.js).
3. **Native AOT Blazor Dashboard:** In partnership with the ASP.NET Core team, the Aspire Dashboard—built on Blazor Server and Fluent UI v5—now compiles via **Native AOT** into a self-contained ~93 MB binary containing the entire runtime and garbage collector, delivering instantaneous startup without requiring a host .NET installation.
4. **The Zero-.NET Dependency Toolchain (`.aspire` bundle):** Developers using TypeScript, Go, or Python never need to install the .NET SDK. Everything—the Aspire CLI, `Aspire.Managed` orchestration engine, Developer Control Plane (DCP in Go), and terminal emulator—is packaged into a pre-compiled native bundle acquired via Brew, Winget, npm, Nix, Mise, or shell scripts.

![Session Title Slide](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/01_title_aspire_agent_toolchain.webp)

---

## Architecture: Cross-Language Aspire Orchestration

```mermaid
sequenceDiagram
    autonumber
    participant TS as Guest AppHost (Node / TypeScript)
    participant CLI as Native AOT Aspire CLI
    participant AM as Aspire.Managed (Native AOT C# Engine)
    participant DCP as Developer Control Plane (Go)
    participant DB as Native AOT Dashboard (Blazor Server)

    Note over TS,CLI: Developer runs 'aspire start' (No .NET required on host)
    CLI->>AM: Launch Aspire.Managed server
    AM->>DCP: Start container runtime & endpoint allocation
    AM->>DB: Spin up Blazor Server Dashboard (gRPC & OTLP)
    
    TS->>AM: JSON-RPC: ATS Capability Discovery (addRedis, withEnvironmentCallback)
    TS->>AM: JSON-RPC: Register Resource ('cache', 'worker')
    TS->>AM: JSON-RPC: Register Callback ('callback_1_xxx')
    
    AM->>DCP: Provision Redis Container & Node Process
    Note over AM,TS: Resource Execution Phase
    AM->>TS: JSON-RPC: Invoke Callback 'callback_1_xxx'
    Note over TS: Node evaluates TS expression: ['Hello', 'from', ...].join(' ')
    TS->>AM: JSON-RPC: context.environment.set("DEMO_MESSAGE", value)
    AM-->>TS: Acknowledge Environment Set
    AM->>DB: Stream Live Status & Endpoints via SignalR
```

---

## 1. Why Aspire Went Polyglot: The Trojan Horse Evolution

In early versions of Aspire, setting up distributed orchestration required a `.csproj` and `Program.cs`. While natural for .NET developers, non-.NET teams (particularly JavaScript/TypeScript frontend engineers) balked at adopting MSBuild project files. 

![Why Aspire went polyglot](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/02_trojan_horse_multilanguage.webp)

* **Phase 1: Project-Based AppHost (`.csproj` + `Program.cs`):** Powerful for .NET-only shops; rejected by polyglot teams.
* **Phase 2: File-Based `apphost.cs`:** A single C# file requiring no project file. Simpler, but frontend developers still resisted writing C#.
* **Phase 3: Universal ATS Polyglot AppHosts:** Native TypeScript (`apphost.mts`), Go (`apphost.go`), Python, and Rust, where .NET acts as the invisible high-performance engine underneath.

---

## 2. The Aspire Type System (ATS) & Multi-Language Generation

The Aspire team explored transpiling TypeScript into C# via Roslyn source generators, but hit a fatal roadblock: **callbacks**. Aspire app hosts rely heavily on lambdas and deferred callbacks (e.g. inspecting dynamic container ports or environment variables at execution time). Static source generators cannot execute a TypeScript runtime lambda from compiled C#.

### The ATS Architecture Pipeline

![One API, many languages: ATS Pipeline](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/03_aspire_type_system_architecture.webp)

1. **C# API Declaration:** The Aspire team writes core orchestration logic in C# using extension methods marked with `[AspireExport]`.
2. **Roslyn Extraction:** Roslyn analyzes method signatures, documentation, parameter types, and capability IDs.
3. **ATS Contract:** Forms the least common denominator type system across target languages.
4. **Guest SDK Generation:** Automated code generators produce native TypeScript, Go, and Python packages.
5. **JSON-RPC Dispatch Table:** The Native AOT .NET host maps incoming capability IDs to C# method calls over a bi-directional JSON-RPC channel.

### Bridging Language Mismatches with `[AspireUnion]`
C# supports rich method overloading, which is absent or structurally different in TypeScript and Go. To prevent API drift, Aspire introduces internal dispatcher methods decorated with `[AspireUnion]`:

![C# overloads become one TS method via AspireUnion](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/07_guest_languages_roadmap.webp)

```csharp
// Public C# overloads: hidden from TypeScript generation
[AspireExportIgnore(Reason = "Polyglot AppHosts use the internal dispatcher")]
public static IResourceBuilder<T> WithEnvironment<T>(this IResourceBuilder<T> builder, string name, string? value);

// Single internal dispatcher exported to ATS
[AspireExport]
internal static IResourceBuilder<T> WithEnvironment<T>(
    this IResourceBuilder<T> builder, 
    string name,
    [AspireUnion(typeof(string), typeof(ReferenceExpression), typeof(EndpointReference))] object value) 
{
    return value switch {
        string s => builder.WithEnvironment(name, s),
        EndpointReference e => builder.WithEnvironment(name, e),
        ReferenceExpression r => builder.WithEnvironment(name, r),
        _ => throw new NotSupportedException()
    };
}
```

In TypeScript, this maps cleanly into native union types:
```typescript
const endpoint = await redis.getEndpoint("tcp");
await api.withEnvironment("REDIS_HOST", endpoint);
await api.withEnvironment("REDIS_URL", refExpr`redis://${endpoint}:6379`);
```

---

## 3. Deep Dive: Bi-Directional JSON-RPC Execution

To prove that evaluation happens in the guest runtime rather than compiled C#, Jose demonstrated an `apphost.mts` setting an environment variable via `array.join()`:

### C# AppHost vs TypeScript AppHost
```csharp
// AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
builder.AddRedis("cache");
builder.AddExecutable("worker", "node", "../worker", "worker.mjs")
    .WithEnvironment(context => {
        context.EnvironmentVariables["DEMO_MESSAGE"] = "Hello from the shared Aspire engine";
    });
builder.Build().Run();
```

![C# AppHost Callback](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/04_csharp_apphost_callback.webp)

```typescript
// apphost.mts
builder.addExecutable("worker", "node", "../worker", ["worker.mjs"])
    .withEnvironmentCallback(async (context) => {
        console.log(".NET called our TS function (Node " + process.version + ")");
        const value = ["Hello", "from", "the", "shared", "Aspire", "engine"].join(" ");
        await context.environment().set("DEMO_MESSAGE", value);
        console.log(".NET acknowledged; returning");
    });
```

![TypeScript AppHost Callback Source](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/05_typescript_apphost_source.webp)

### Live JSON-RPC Execution Trace
Inspecting the stdout/stderr trace between the TypeScript process and `Aspire.Managed` reveals the bi-directional protocol in action:

![JSON-RPC execution logs between TS AppHost and .NET Engine](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/06_jsonrpc_apphost_execution_logs.webp)

1. `[ATS] Discovered: Aspire.Hosting/withEnvironmentCallback`
2. `.NET >> invokeCapability(Aspire.Hosting.Redis/addRedis) args: {"name":"cache"}`
3. `TS Registering callback`
4. `.NET >> invokeCapability(Aspire.Hosting/withEnvironmentCallback) args: {"callback":"callback_1_1794352288934"}`
5. `.NET Callback callback_1_... started on connection ..., timeout 00:01:00`
6. `TS .NET called our TS function (Node v26.13.0, pid 81720)`
7. `TS Asking .NET to set the environment`
8. `.NET >> invokeCapability(Aspire.Hosting.ApplicationModel/set) args: {"name":"DEMO_MESSAGE", "value":"Hello from the shared Aspire engine"}`
9. `TS .NET acknowledged; returning`
10. `.NET Callback finished after 00:00:00.0385197 (38ms)`

---

## 4. The Aspire Dashboard: Control Center Architecture

The Aspire Dashboard is a standalone OpenTelemetry and resource management platform built on **Blazor Server** and **Fluent UI v5**.

![The Dashboard is your control center](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/08_dashboard_architecture_blazor_fluent.webp)

The dashboard integrates 5 concurrent subsystems:
1. **DCP (Developer Control Plane):** Written in Go; manages local containers, executables, and port mappings.
2. **Resource Service:** Streams live state and lifecycle transitions from `AppHost` over gRPC.
3. **OTLP Receiver:** Ingests OpenTelemetry traces, structured logs, and metrics directly from child applications.
4. **Interaction Service:** Bi-directional prompt channel that alerts developers or autonomous agents when parameters, secrets, or cloud credentials are missing.
5. **Blazor Server UI:** Renders real-time telemetry and resource state, pushing DOM diffs over SignalR websockets.

### Fluent UI v5 & Native AOT Blazor
* **Agent-Driven Migration:** Migrating the entire Aspire dashboard to Fluent UI v5 was executed by James Newton-King using autonomous AI coding agents, completing a massive multi-month refactoring in weeks.
* **Native AOT Blazor Compilation:** In collaboration with the ASP.NET Core team, the dashboard now compiles down to a single Native AOT binary (`Aspire.Dashboard.exe`), eliminating the managed runtime bundle and cutting cold start times to near-zero.

---

## 5. The Zero-.NET Native Bundle (`~/.aspire/bundle`)

Aspire 17 decouples completely from the user's local .NET SDK installation. 

![Native AOT Aspire Bundle Directory](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/09_native_aot_aspire_bundle.webp)

### Contents of `~/.aspire/bundle/`:
* **`dashboard/` (`Aspire.Dashboard.exe` - ~93 MB):** Standalone Native AOT executable housing Blazor Server, the embedded Kestrel server, and the .NET Garbage Collector.
* **`dcp/`:** Native Go binary for local container control.
* **`Aspire.Managed`:** The Native AOT orchestration engine that executes ATS capability calls.
* **`terminal-host/` (`hex10pty.exe`, `conpty.dll`):** Native pseudoterminal host powering the in-dashboard interactive web terminal.
* **`tray/`:** Native desktop system tray application for one-click dashboard access.

### Acquisition Channels
Developers install the single native `aspire` CLI via:
* **macOS / Linux:** `brew install aspire`, `nix`, or `mise`
* **Windows:** `winget install Microsoft.Aspire`
* **Web / Node devs:** `npm install -g @aspire/cli`
* **Universal Script:** `curl -sSL https://get.aspire.dev | bash`

### Clean WSL Linux Verification (No .NET Installed)
In a freshly created Ubuntu WSL instance with **zero .NET SDK or runtime installed**, Jose ran `aspire start` on a TypeScript apphost. The dashboard and resources orchestrated immediately:

![Clean WSL demo running Aspire without .NET](/dotnetconf2026/archive/15-aspire-agent-first-toolchain/screenshots/10_wsl_no_dotnet_installed_demo.webp)

```bash
demo@DESKTOP-2S86PVR:~/demo2$ ls
README.md apphost.mts package.json tsconfig.json ...

demo@DESKTOP-2S86PVR:~/demo2$ aspire start
AppHost:   apphost.mts
Dashboard: http://localhost:15144/login?t=...
[✔] AppHost started successfully.

demo@DESKTOP-2S86PVR:~/demo2$ dotnet --version
Command 'dotnet' not found, but can be installed with:
apt install dotnet-host-10.0
```

---

## Key Takeaways

1. **Aspire is Not Just for .NET Developers:** With TypeScript GA, Go in preview for Aspire 17, and Python/Rust on the horizon, any engineering team can adopt Aspire without learning C# or installing the .NET runtime.
2. **.NET as a Power Substrate:** Aspire showcases .NET 11's ability to act as a world-class systems platform—combining Native AOT, Blazor, Roslyn analysis, and high-throughput JSON-RPC into a frictionless cross-language developer tool.
3. **Agent-Ready Architecture:** Clean separation of concerns, JSON-RPC capability contracts, and the Interaction Service make Aspire the ideal environment for multi-agent autonomous software engineering.
