Skip to main content
Any Framework

MSBuild task to generate compilable C# public API stubs from built .NET assemblies.

Published
May 31, 2026
4mo ago
Total Downloads
3.0K
3,041

Install

dotnet add package Meziantou.Framework.PublicApiGenerator.MSBuild --version 1.0.5

No framework information available.

README

Meziantou.Framework.PublicApiGenerator.MSBuild

Meziantou.Framework.PublicApiGenerator.MSBuild generates a public API file during dotnet build.

Usage

Add the package reference and configure the required output path property:

<ItemGroup>
  <PackageReference Include="Meziantou.Framework.PublicApiGenerator.MSBuild" Version="x.y.z" PrivateAssets="all" />
</ItemGroup>

<PropertyGroup>
  <PublicApiGeneratorOutputPath>PublicApi/PublicApi.g.cs</PublicApiGeneratorOutputPath>
</PropertyGroup>

Configuration

  • PublicApiGeneratorGenerateOnBuild (default: true)
  • PublicApiGeneratorVerifyNoChangeOnBuild (default: false) - verifies generated public API files are up to date without writing files
  • PublicApiGeneratorOutputPath (required)
  • PublicApiGeneratorFileLayout (SingleFile, OneFilePerNamespace, OneFilePerType; default: SingleFile)
  • PublicApiGeneratorIncludeAutoGeneratedComment (default: true)

When PublicApiGeneratorVerifyNoChangeOnBuild is true, verification mode takes precedence and no files are written.

Example for CI:

dotnet build -p:PublicApiGeneratorVerifyNoChangeOnBuild=true

For multitargeted projects, generation runs once after all target frameworks are built and merges all output assemblies.

Changes from Previous Version

No structural changes between v1.0.4 and v1.0.5.

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.