Skip to main content
Any Framework

CLI to generate compilable C# public API stubs from .NET assemblies.

Published
Jul 8, 2026
3mo ago
Total Downloads
4.2K
4,182

Install

dotnet add package Meziantou.Framework.PublicApiGenerator.Tool --version 2.0.1

No framework information available.

README

Meziantou.Framework.PublicApiGenerator.Tool

Meziantou.Framework.PublicApiGenerator.Tool is a CLI tool that reads a .NET .dll or .exe and generates compilable C# files describing its public API.

Install

dotnet tool install --global Meziantou.Framework.PublicApiGenerator.Tool

Example

Meziantou.Framework.PublicApiGenerator.Tool \
  --input ./bin/Release/net10.0/MyLibrary.dll \
  --output ./public-api \
  --file-layout OneFilePerNamespace \
  --omit-auto-generated-comment

Multi-target example:

Meziantou.Framework.PublicApiGenerator.Tool \
  --input netstandard2.0=./bin/Release/netstandard2.0/MyLibrary.dll \
  --input net10.0=./bin/Release/net10.0/MyLibrary.dll \
  --output ./public-api \
  --omit-auto-generated-comment

When using multiple --input values, you can use tfm=path to set the target framework explicitly, or use plain paths and let the tool infer target frameworks from assembly metadata (TargetFrameworkAttribute).

--output is the output directory option.

When using --file-layout SingleFile, you can use --output-file to set an explicit file path instead of generating PublicApi.g.cs in the output directory.

Meziantou.Framework.PublicApiGenerator.Tool \
  --input ./bin/Release/net10.0/MyLibrary.dll \
  --output-file ./public-api/MyLibrary.PublicApi.cs \
  --file-layout SingleFile

Use --verify-no-change to check that generated files are up to date without writing any file. This is useful in CI:

Meziantou.Framework.PublicApiGenerator.Tool \
  --input ./bin/Release/net10.0/MyLibrary.dll \
  --output-file ./public-api/MyLibrary.PublicApi.cs \
  --file-layout SingleFile \
  --verify-no-change

Example output

public-api/
  Demo.g.cs
  GlobalNamespace.g.cs

Help

Description:
  Generate public API stubs from a .NET assembly.

Usage:
  Meziantou.Framework.PublicApiGenerator.Tool [options]

Options:
  --input <input> (REQUIRED)                                     Assembly input. Use either 'path' or 'tfm=path'. Repeat for multi-target generation.
  --output <output>                                              Output directory
  --output-file <output-file>                                    Output file path when --file-layout is SingleFile
  --file-layout <OneFilePerNamespace|OneFilePerType|SingleFile>  File layout: SingleFile, OneFilePerNamespace, or OneFilePerType [default: SingleFile]
  --omit-auto-generated-comment                                  Omit the // <auto-generated/> comment from generated files
  --verify-no-change                                             Verify generated files are up to date without writing changes
  -?, -h, --help                                                 Show help and usage information
  --version                                                      Show version information

Changes from Previous Version

No structural changes between v2.0.0 and v2.0.1.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.