Skip to main content
.NETStandard2.0

A source generator for exposing information about your project at compile time

Published
Oct 22, 2026
25d ago
Total Downloads
360.4K
360,449

Install

dotnet add package NetEscapades.ProjectInfo --version 0.1.0-beta2
ProductVersions
.NET Standard
netstandard2.0

README

NetEscapades.ProjectInfo

Build status NuGet

NetEscapades.ProjectInfo is a small source generator that echoes values from your project file into a generated ProjectInfo class, as const string values or as ReadOnlySpan<byte> UTF-8 literals.

Adding NetEscapades.ProjectInfo to your project

Add the package to your application using

dotnet add package NetEscapades.ProjectInfo

You can mark the package as PrivateAssets="all", as nothing from it is needed at runtime.

Usage

Declare the values you want in your .csproj file:

<ItemGroup>
  <ProjectInfoString Include="Version" Value="1.2.3" />
  <ProjectInfoUtf8 Include="VersionBytes" Value="4.5.6" />
</ItemGroup>

This generates the following class:

#nullable enable
internal static partial class ProjectInfo
{
    public const string Version = "1.2.3";
    public static global::System.ReadOnlySpan<byte> VersionBytes => "4.5.6"u8;
}
  • ProjectInfoString generates a public const string.
  • ProjectInfoUtf8 generates a ReadOnlySpan<byte> property using a "..."u8 literal. This requires C# 11 or later (and a target that has ReadOnlySpan<byte>, e.g. the System.Memory package on .NET Framework).
  • The item name (Version) is the member name, and the Value metadata is the value. Nothing is generated if you don't declare any items.

The class is generated in your project's <RootNamespace> if one is set, otherwise in the global namespace. It is internal and partial by default; set <ProjectInfoVisibility>public</ProjectInfoVisibility> to make it public.

Diagnostics

Invalid items are reported as errors and skipped; other items are still generated.

ID Meaning
NEPI001 The item name is not a valid C# identifier (or is ProjectInfo)
NEPI002 The item name is defined more than once (the first definition wins)
NEPI003 The item has no (or an empty) Value
NEPI004 ProjectInfoUtf8 is used with a language version lower than C# 11
NEPI005 An item could not be read: values containing a back-quote (`) are not supported

Changes from Previous Version

No structural changes between v0.1.0-beta1 and v0.1.0-beta2.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

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