AspireC4.Hosting
13.6.4-preview.2
See the version list below for details.
dotnet add package AspireC4.Hosting --version 13.6.4-preview.2
NuGet\Install-Package AspireC4.Hosting -Version 13.6.4-preview.2
<PackageReference Include="AspireC4.Hosting" Version="13.6.4-preview.2" />
<PackageVersion Include="AspireC4.Hosting" Version="13.6.4-preview.2" />
<PackageReference Include="AspireC4.Hosting" />
paket add AspireC4.Hosting --version 13.6.4-preview.2
#r "nuget: AspireC4.Hosting, 13.6.4-preview.2"
#:package AspireC4.Hosting@13.6.4-preview.2
#addin nuget:?package=AspireC4.Hosting&version=13.6.4-preview.2&prerelease
#tool nuget:?package=AspireC4.Hosting&version=13.6.4-preview.2&prerelease
AspireC4.Hosting
An Aspire integration that generates a live LikeC4 architecture diagram from your AppHost's resource graph, and hosts it in the Aspire dashboard.
Prerequisites
- .NET 10 or later. This package targets
net10.0, so the AppHost that references it must too. - Aspire 13.5.3 or later. The AppHost must reference both the AppHost SDK and
Aspire.Hosting.AppHost. - Docker (or Podman) for the default LikeC4 sidecar container.
- Optional: a local Node.js CLI runtime (
npx,pnpm,yarn,bunordeno) if you call.WithLocalCLI()instead.
Container image exports verify bind sharing through Purview.Containers.Environment, using
alpine:3.19 by default. Offline environments must preload the probe image or set
CONTAINER_ENVIRONMENT_PROBE_IMAGE. For a daemon inside WSL or a shared remote filesystem,
also install Purview.Containers.Aspire and call builder.AddContainerEnvironment()
to adapt the live sidecar's mounts. See the
container environment guide
for verified path mappings, write permissions and remote-host limitations.
Installation
Add the package to the AppHost project:
dotnet add package AspireC4.Hosting
<Project Sdk="Aspire.AppHost.Sdk/13.5.3">
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="AspireC4.Hosting" />
</ItemGroup>
</Project>
Quick start
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAspireC4();
builder.AddProject<Projects.Api>("api");
builder.Build().Run();
When the AppHost starts, this writes ./.aspirec4/likec4/model.gen.c4 and starts the LikeC4 server.
The diagram refreshes as the Aspire app changes. Open it from the aspirec4 resource in the dashboard.
Screenshots

The image above is captured from the sample AppHost in the
repository and stored in docs/images/screenshots/. Your own
diagram exports a PNG for every view to ./.aspirec4/images/ on startup (ExportImages), which is the
easiest way to capture one.
Configuration
Configure the diagram in the configure callback, or through the AspireC4 configuration section.
builder.AddAspireC4(configure: options => options
.WithTitle("Orders platform")
.WithViewTitle("Architecture")
.WithHideFromDashboard());
| Property | Default | Description |
|---|---|---|
Title |
null |
Title shown in the LikeC4 app |
ViewTitle |
"Architecture" |
Title of the generated view |
ViewDescription |
null |
Optional view description |
OutputDirectory |
"./.aspirec4/likec4/" |
Where the generated .c4 file is written |
ProjectDirectory |
null |
An existing LikeC4 project to generate into and serve |
FileName |
"model.gen" |
Generated file name without extension |
DisableHMR |
false |
Disable Hot Module Replacement |
HMRPort |
null |
Fixed HMR port. Allocated dynamically by default |
ContainerImageTag |
null (latest) |
Pin the ghcr.io/likec4/likec4 image tag |
AutoIconsEnabled |
true |
Infer LikeC4 icons from resource type and name |
HideFromDashboard |
false |
Hide the LikeC4 sidecar from the dashboard |
IncludeAspireDashboardLinks |
true |
Link diagram elements back to the Aspire dashboard |
ExportImages |
true |
Export every view as an image to ./.aspirec4/images/ when the model changes |
ImageFormats |
{Png} |
Png and/or Jpg |
UseLegacyLayout |
false |
Restore the pre-13.6 output paths and dashboard names |
Run LikeC4 locally instead of in a container
builder.AddAspireC4().WithLocalCLI();
Use your own LikeC4 project
Serve a LikeC4 project you already maintain. The generated model is added to it as one more file, and
your likec4.config.json, .c4 sources and views are left alone.
builder.AddAspireC4(configure: options => options
.WithLikeC4ProjectFolder("../../architecture"));
builder.AddProject<Projects.Api>("api")
.WithLikeC4Element("cloud.backend.api"); // attach live state to an element you declared
Describing resources
var db = builder.AddPostgres("pg").AddDatabase("orders");
builder.AddProject<Projects.Api>("api")
.WithLikeC4Details(details => details
.WithLabel("Public API")
.WithTechnology(".NET")
.WithDescription("The public HTTP API surface.")
.WithIcon("tech:dotnet")
.WithTag("backend"))
.WithLikeC4Reference(db, opts => opts.WithLabel("Persists orders")) // also calls WithReference
.WithLikeC4Group("Platform");
builder.AddContainer("debug-tools", "busybox")
.ExcludeFromLikeC4();
Compile-time validation
The package includes a source generator that checks the values passed to .WithTag(), .WithKind(),
.WithLikeC4Group() and .WithMetadata() against a registry class in your AppHost. You do not need
to reference anything else.
using Aspire.Hosting.AspireC4;
[LikeC4Registry(Strict = LikeC4Severity.Warning)]
internal static class ArchitectureRegistry
{
public static class Tags
{
public const string Backend = "backend";
}
public static class Groups
{
public const string Platform = "Platform";
}
}
Set the project-wide severity with <AspireC4Strict>warning</AspireC4Strict>, and add your .c4
files as <AdditionalFiles> to validate against their specification blocks too. The diagnostics are
ASPIREC4001 to ASPIREC4007.
TypeScript AppHosts
The same API is exported to TypeScript AppHosts in camel case (addAspireC4, withLikeC4Details, …).
Add "AspireC4.Hosting" to the packages in aspire.config.json and run aspire restore.
ER diagrams from Entity Framework Core
Add AspireC4.Hosting.EntityFrameworkCore
to the AppHost and call .WithEntityFrameworkDiagram() to add a live ER diagram of your DbContext
types, linked from the architecture diagram.
It is additive, and optional: AddAspireC4() stays exactly as it is, and
WithEntityFrameworkDiagram() is an extension on the builder it returns, so the two diagrams run side by
side — or you keep the architecture diagram on its own and never install the package. The ER diagram has
its own renderers (Interactive by default, plus Mermaid, Dbml and D2) and options; see that
package's README.
More information
| Product | Versions 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. |
-
net10.0
- Aspire.Hosting (>= 13.6.4)
- Purview.Containers.Environment (>= 1.0.0-prerelease.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AspireC4.Hosting:
| Package | Downloads |
|---|---|
|
AspireC4.Hosting.EntityFrameworkCore
Aspire hosting extension for AspireC4, generating a live d2lang ER diagram from Entity Framework Core DbContext types. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 17.0.0 | 145 | 11/26/2026 |
| 17.0.0-prerelease.4 | 108 | 11/22/2026 |
| 17.0.0-prerelease.3 | 80 | 11/21/2026 |
| 17.0.0-prerelease.2 | 104 | 11/20/2026 |
| 17.0.0-prerelease.1 | 120 | 11/19/2026 |
| 13.6.5 | 402 | 11/16/2026 |
| 13.6.5-preview.1 | 96 | 11/12/2026 |
| 13.6.4-preview.3 | 81 | 11/8/2026 |
| 13.6.4-preview.2 | 124 | 10/31/2026 |
| 13.6.4-preview.1 | 93 | 10/29/2026 |
| 13.6.0-preview.4 | 82 | 10/27/2026 |
| 13.6.0-preview.3 | 102 | 10/24/2026 |
| 13.6.0-preview.2 | 110 | 10/22/2026 |
| 13.6.0-preview.1 | 100 | 10/18/2026 |
| 13.5.3.11 | 425 | 10/7/2026 |
| 13.5.3.10 | 118 | 9/29/2026 |
| 13.5.3.9 | 127 | 9/29/2026 |
| 13.5.3.8 | 131 | 9/28/2026 |
| 13.5.3.7 | 127 | 9/27/2026 |
| 13.5.3.6 | 129 | 9/25/2026 |