Skip to content
Purview Dev logo

AspireC4

Stable AspireC4 Reviewed 2026-10-18 purview-dev/aspirec4 Star on GitHub 9 architecture architecture-as-code architecture-diagrams aspire aspire-dashboard aspire-dotnet aspire-hosting aspnetcore c4 c4-model developer-experience devex diagram diagrams dotnet likec4 roslyn source-generator visualization llms.txt

This guide walks through installing AspireC4 and generating your first live architecture diagram.

  • .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, or deno) if you call .WithLocalCLI().

Add AspireC4 to the AppHost project:

Terminal window
dotnet add package AspireC4.Hosting
dotnet add package Aspire.Hosting.AppHost

An 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>

Add the visualization to your AppHost:

var builder = DistributedApplication.CreateBuilder(args);
builder.AddAspireC4();
builder.Build().Run();

That is all it takes. On startup AspireC4:

  1. Writes the generated model to ./.aspirec4/likec4/model.gen.c4 (relative to the AppHost working directory).
  2. Starts the official ghcr.io/likec4/likec4 container as a sidecar resource named aspirec4.
  3. Refreshes the diagram whenever the Aspire application changes — for example when a resource transitions to Running or Exited.

Open the Aspire dashboard and select the aspirec4 resource (or its View LikeC4 Diagram link) to see the live 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.

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.

AspireC4 supports both C# and TypeScript AppHosts. See TypeScript AppHosts for the TypeScript API and a runnable sample.