This repository distributes the DocFX builder image, shared templates and native multi-framework documentation generator.
Use framework views to generate one native set of API pages, xrefs and search results per target framework. The same PowerShell entry point runs on Windows, Linux, CI and in the builder image. Ordinary DocFX sites continue to use the standard CLI.
Consuming repositories only need to provide their DocFX metadata and content with a command such as ADD [".", "docfx"] in their documentation Dockerfile.
The image includes DocFX's default and modern templates and the Codebelt ms-style compatibility overlay. The overlay is intended for API reference sites maintained by the Codebelt ecosystem, including:
- Cuemon
- SavvyIO
- Shared-Kernel
- Unitify
- Bootstrapper
- xUnit
- BenchmarkDotNet
- YamlDotNet
- Carter
- Globalization
- ASP.NET API Versioning
- Swashbuckle.AspNetCore
- Newtonsoft.Json
- AWS Signature V4
An existing build can adopt the shared template with a small docfx.json change:
{
"build": {
"template": [
"default",
"modern",
"templates/ms-style"
]
}
}DocFX merges templates from left to right. Keep an existing repository template before templates/ms-style when it supplies repository-specific partials that should remain available.
Put a deliberate local override after templates/ms-style when it must take precedence.
For Microsoft Learn-style type pages, add memberLayout to every managed-reference metadata entry:
{
"metadata": [
{
"src": [ /* existing project sources */ ],
"dest": "api",
"memberLayout": "separatePages"
}
]
}This preserves existing generated YAML, Markdown, TOCs, overwrite files, filters, and source-link metadata.
ms-style changes the API reading surface with:
- type-first headings such as
DateTime Structand a Definition/facts block; - Learn-like type/member tables, namespace category tables, and a narrow article column with a wide-screen navigation rail that collapses into an inline article outline on narrower desktops; and
- responsive light/dark styling.
It does not reproduce Microsoft's dynamic global navigation, account controls, product switcher, or other Learn platform services. Those are outside a DocFX template's responsibility.
The smooth migration path is therefore:
- build or update the shared DocFX image so it contains
ms-style; - append
templates/ms-styleto the existing template array; - set
memberLayouttoseparatePagesfor each API metadata source; - build and visually review one representative type and member page; and
- remove only custom template files that duplicate the shared shell after the new output has been accepted.
The shared image contains the template files. After changing ms-style, rebuild the shared image before rebuilding consuming repositories. Without --pull, Docker uses an existing local image with the requested tag and downloads it only when that image is not available locally. This supports a local-first feedback loop without accidentally replacing a locally built image with the published one.
Static documentation hosts should serve content-hashed assets with a long-lived immutable policy and serve stable DocFX URLs with Cache-Control: no-store. The ms-style page shell also requests same-origin JSON with the Fetch API's no-store cache mode. This bypasses navigation data cached before explicit response policies were added; response headers alone cannot invalidate an entry when the browser satisfies the request without contacting the server.
The visual target is the .NET API reference surface represented by Microsoft Learn.
API source and content conventions are informed by dotnet-api-docs and dotnet/docs.
For the underlying template model, see:
From the repository root, use PowerShell 7 and Docker Buildx in Linux-container mode.
pwsh -NoProfile -File ./BuildAndPushDocfxImage.ps1 -Tag docfx-localThe default loads one platform into Docker and tags it as docfx-local:2.81.0, docfx-local:2.81, docfx-local:2, and docfx-local:latest. Supply -Platform linux/amd64 or -Platform linux/arm64 to select a platform explicitly. AMD64 uses Alpine and ARM64 uses Ubuntu 26.04, whose .NET 11 SDK includes PowerShell 7 on ARM64. Use the corresponding package manager when extending either image.
The script accepts -DocfxVersion for the CLI and upstream templates and -DotnetVersion for the SDK and runtime used by DocFX. The defaults package DocFX 2.81.0 and the .NET 10 and .NET 11 SDKs. Use -FrameworkSdkImage or -FrameworkSdkArm64Image to override the final SDK base on the corresponding platform. Keep the base's C library compatible with that platform's SDK stage and ensure the base supplies PowerShell 7. The framework views compatibility contract applies when changing the CLI or template.
For an authorized release, select a Buildx builder that can build linux/amd64 and linux/arm64, using native nodes or emulation. Use docker buildx inspect --bootstrap to check the builder's platforms. If needed, create a builder with docker buildx create --driver docker-container --name docfx-release --use. Sign in to the destination registry and run the publishing script from the repository root.
pwsh -NoProfile -File ./BuildAndPushDocfxImage.ps1 -PublishExisting release callers must add -Publish. The script sends one multi-platform build directly to the registry under the exact, major/minor, major, and latest tags. It verifies that all four tags resolve to the built index digest and fetches both required image configs to verify their platforms. On success it prints codebeltnet/docfx:2.81.0@sha256:<image-index-digest>. Use -ContainerRegistry and -Tag for a different registry namespace or repository.
Inspect the exact tag to retrieve the digest and platform list after release.
docker buildx imagetools inspect codebeltnet/docfx:2.81.0Use the top-level Digest field in codebeltnet/docfx:2.81.0@sha256:<image-index-digest>. Record the digest from the approved release alongside the source commit. The version tags can move, including the exact CLI tag when builder content changes. See Run in the builder image for the consumer command.