AspireC4.Hosting
17.0.0-prerelease.2
See the version list below for details.
dotnet add package AspireC4.Hosting --version 17.0.0-prerelease.2
NuGet\Install-Package AspireC4.Hosting -Version 17.0.0-prerelease.2
<PackageReference Include="AspireC4.Hosting" Version="17.0.0-prerelease.2" />
<PackageVersion Include="AspireC4.Hosting" Version="17.0.0-prerelease.2" />
<PackageReference Include="AspireC4.Hosting" />
paket add AspireC4.Hosting --version 17.0.0-prerelease.2
#r "nuget: AspireC4.Hosting, 17.0.0-prerelease.2"
#:package AspireC4.Hosting@17.0.0-prerelease.2
#addin nuget:?package=AspireC4.Hosting&version=17.0.0-prerelease.2&prerelease
#tool nuget:?package=AspireC4.Hosting&version=17.0.0-prerelease.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
- The .NET 11 SDK to build the AppHost. The package's source generator runs inside the compiler
and is built against Roslyn 5.9; an older SDK reports
CS9057and skips it, which drops theASPIREC4xxxvalidation and the[LikeC4Registry]types. - A
net10.0ornet11.0AppHost. This package ships both assets; an AppHost targetingnet10.0(the Aspire AppHost framework) resolves thenet10.0one. .NET 8 and .NET 9 are not supported. - Aspire 13.6.5 or later, on the 13 line (an
Aspire.AppHost.SdkAppHost) or 17 and later (aMicrosoft.NET.SdkAppHost referencingAspire.Hosting.AppHost). One package serves both. - 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.
The requirements page has the detail behind each of these.
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="Microsoft.NET.Sdk">
<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 |
Recognise each resource's technology and icon from its framework (including a .NET project's flavour), Aspire type or container image, and fuzzy-match the rest. See Technology and icons |
TechnologyOverrides |
[] |
App-wide rules that name the technology and icon by package, resource type or container image, before the built-in catalogue: WithPackageTechnology, WithResourceTypeTechnology, WithContainerImageTechnology. See Overriding it |
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 |
ExtensionsDirectory |
"./likec4-extensions" |
Hand-written .c4 files beside the AppHost, included automatically when the folder exists |
GenerateGitIgnoreFile |
true |
Write .gitignore files that keep the generated model out of git |
Run LikeC4 locally instead of in a container
builder.AddAspireC4().WithLocalCLI();
Source control and your own LikeC4 files
Add nothing to .gitignore: AspireC4 writes its own beside the generated files, naming only what it
writes, and never replaces one it did not write. The exported images stay visible to git so they can be
committed. Files are written only when their content changes, so restarting an unchanged application
touches nothing.
Hand-written .c4 files — people, external systems, extend blocks for generated elements, extra
views — go in a likec4-extensions/ folder beside the AppHost, which is included automatically. See
Source control
and
Extending the generated model.
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"))
.WithLikeC4ConnectionReference(db, opts => opts.WithLabel("Persists orders")) // also calls WithReference
.WithLikeC4Group("Platform");
builder.AddContainer("debug-tools", "busybox")
.ExcludeFromLikeC4();
Each element also records where it comes from, with no code: a local .NET, Node, Bun, Python or Go
project gets its project-path (relative to the AppHost) and its runtime version, and a container gets its
full container-image reference and tag. See
where each resource comes from.
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. net11.0 is compatible. |
-
net10.0
- Aspire.Hosting (>= 13.6.5)
- Purview.Containers.Environment (>= 1.0.0-prerelease.14)
-
net11.0
- Aspire.Hosting (>= 13.6.5)
- Purview.Containers.Environment (>= 1.0.0-prerelease.14)
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 | 161 | 11/26/2026 |
| 17.0.0-prerelease.4 | 109 | 11/22/2026 |
| 17.0.0-prerelease.3 | 81 | 11/21/2026 |
| 17.0.0-prerelease.2 | 105 | 11/20/2026 |
| 17.0.0-prerelease.1 | 121 | 11/19/2026 |
| 13.6.5 | 460 | 11/16/2026 |
| 13.6.5-preview.1 | 97 | 11/12/2026 |
| 13.6.4-preview.3 | 86 | 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 | 84 | 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 | 427 | 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 |