AspireC4
Getting Started
Section titled “Getting Started”This guide walks through installing AspireC4 and generating your first live architecture diagram.
Prerequisites
Section titled “Prerequisites”- .NET 8 or later.
- Aspire 13.5.3 or later. Aspire AppHost projects must reference both the AppHost SDK and
Aspire.Hosting.AppHost. - Docker is used by default to run the LikeC4 sidecar container.
- Optional: a local Node.js CLI runtime (
npx,pnpm,yarn,bun, ordeno) if you call.WithLocalCLI().
Installation
Section titled “Installation”Add AspireC4 to the AppHost project:
dotnet add package AspireC4.Hostingdotnet add package Aspire.Hosting.AppHostAn Aspire 13.5 AppHost project should contain the equivalent of:
<Project Sdk="Aspire.AppHost.Sdk/13.5.3"> <ItemGroup> <PackageReference Include="Aspire.Hosting.AppHost" /> <PackageReference Include="AspireC4.Hosting" /> </ItemGroup></Project>Quick start
Section titled “Quick start”Add the visualization to your AppHost:
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAspireC4();
builder.Build().Run();That is all it takes. On startup AspireC4:
- Writes the generated model to
./.aspirec4/likec4/model.gen.c4(relative to the AppHost working directory). - Starts the official
ghcr.io/likec4/likec4container as a sidecar resource namedaspirec4. - Refreshes the diagram whenever the Aspire application changes — for example when a resource transitions to
RunningorExited.
Open the Aspire dashboard and select the aspirec4 resource (or its View LikeC4 Diagram link) to see the live diagram.
Customize the diagram
Section titled “Customize the diagram”Pass a configuration callback to AddAspireC4:
builder.AddAspireC4(options => options .WithTitle("My distributed application") .WithViewTitle("Architecture") .WithViewDescription("Generated from the Aspire resource graph"));See Configuration for the full options reference and Customizing Resources for per-resource details.
Use a local CLI instead of Docker
Section titled “Use a local CLI instead of Docker”When Docker is not available, or you prefer a local Node.js-based workflow:
builder.AddAspireC4().WithLocalCLI();The first runtime available on the system PATH is selected automatically (npx → pnpm → yarn → bun → deno). See Local CLI Runtimes.
Run the TypeScript sample
Section titled “Run the TypeScript sample”AspireC4 supports both C# and TypeScript AppHosts. See TypeScript AppHosts for the TypeScript API and a runnable sample.