Bennewitz.Ninja.AutoVersioning
2026.2.429
Prefix Reserved
See the version list below for details.
dotnet add package Bennewitz.Ninja.AutoVersioning --version 2026.2.429
NuGet\Install-Package Bennewitz.Ninja.AutoVersioning -Version 2026.2.429
<PackageReference Include="Bennewitz.Ninja.AutoVersioning" Version="2026.2.429"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="Bennewitz.Ninja.AutoVersioning" Version="2026.2.429" />
<PackageReference Include="Bennewitz.Ninja.AutoVersioning"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add Bennewitz.Ninja.AutoVersioning --version 2026.2.429
#r "nuget: Bennewitz.Ninja.AutoVersioning, 2026.2.429"
#:package Bennewitz.Ninja.AutoVersioning@2026.2.429
#addin nuget:?package=Bennewitz.Ninja.AutoVersioning&version=2026.2.429
#tool nuget:?package=Bennewitz.Ninja.AutoVersioning&version=2026.2.429
Bennewitz.Ninja.AutoVersioning
A Roslyn incremental source generator that injects assembly metadata attributes and build-time constants into .NET projects at compile time — no AssemblyInfo.cs, no disk writes, full IDE caching.
Requirements
.NET SDK 6.0 or later (requires Roslyn 4.0+ for IIncrementalGenerator support). The consuming project may target any framework — .NET Framework 4.x, .NET Standard, .NET 6+, etc.
Quick Start
1. Add the package:
<PackageReference Include="Bennewitz.Ninja.AutoVersioning" Version="x.x.x" />
2. Enable the generator in your root Directory.Build.props (or any .props / .csproj imported by your build):
<PropertyGroup>
<GenerateAutoVersionedAssemblyInfo>true</GenerateAutoVersionedAssemblyInfo>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AssemblyCompany>YourCompany</AssemblyCompany>
<AssemblyProduct>YourProduct</AssemblyProduct>
<CommitSha Condition="'$(CommitSha)' == ''">$(GITHUB_SHA)</CommitSha>
<IsContinuousIntegration>$(GITHUB_ACTIONS)</IsContinuousIntegration>
<PublicVersion Condition="'$(PublicVersion)' == ''">$(MY_VERSION_VAR)</PublicVersion>
</PropertyGroup>
A ready-to-use template is available at Directory.Build.props.template.
3. Build. The generator runs automatically — no further setup needed.
Tip: View the generated files in your IDE under
Dependencies → Analyzers → *SourceGenerators.
Generated Output
Given a build on 2026-04-29 at 14:35 UTC for company Acme Corp, product Acme App, commit abc1234def, and public version 3.1.0:
AutoVersionedAssemblyInfo.g.cs
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyDescription("Assembly Version: 2026.2.429.1435")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCompany("Acme Corp")]
[assembly: AssemblyProduct("Acme App v2026.2.429.1435")]
[assembly: AssemblyCopyright("Copyright 2026 [Release]")]
[assembly: AssemblyVersion("2026.2.429.1435")]
[assembly: AssemblyFileVersion("2026.2.429.1435")]
[assembly: AssemblyInformationalVersion("Commit♥: abc1234def")]
[assembly: AssemblyMetadata("CommitSha", "abc1234def")]
[assembly: AssemblyMetadata("GITHUB_SHA", "abc1234def")]
[assembly: AssemblyMetadata("PublicVersion", "3.1.0")]
DirectoryBuildInfo.g.cs
// <auto-generated/>
namespace Bennewitz.Ninja.AutoVersioning
{
/// <summary>Build-time constants generated by the source generator.</summary>
public static class DirectoryBuildInfo
{
public const string BuildRelease = "Version 2026.2.429.1435 [built 4/29/2026 2:35:00 PM (UTC)]";
}
}
Use DirectoryBuildInfo.BuildRelease wherever you need the build version at runtime — error trackers, log enrichment, health endpoints — without reading environment variables.
Configuration Reference
| MSBuild Property | Description | Required |
|---|---|---|
GenerateAutoVersionedAssemblyInfo |
Set to true to enable the generator |
Yes |
AssemblyCompany |
Value for [assembly: AssemblyCompany(...)] |
Yes |
AssemblyProduct |
Value for [assembly: AssemblyProduct(...)] |
Yes |
CommitSha |
Git commit SHA | No |
IsContinuousIntegration |
true on CI runs |
No |
PublicVersion |
Your app's public-facing version string | No |
Configuration |
Debug / Release — set automatically by MSBuild |
Auto |
CI Provider Mappings
| Provider | Commit SHA | CI flag |
|---|---|---|
| GitHub Actions | $(GITHUB_SHA) |
$(GITHUB_ACTIONS) |
| GitLab CI | $(CI_COMMIT_SHA) |
$(GITLAB_CI) |
| Bitbucket Pipelines | $(BITBUCKET_COMMIT) |
$(CI) |
Version Format
The generator uses CalVer: YEAR.QUARTER.MMDD.HHmm
| Part | Example | Meaning |
|---|---|---|
| Major | 2026 |
Calendar year |
| Minor | 2 |
Quarter (1–4) |
| Build | 429 |
Month + day (MMdd as integer) |
| Revision | 1435 |
Hour + minute (HHmm as integer) |
How It Works
This is a modern C# IIncrementalGenerator. Compared to legacy ISourceGenerator approaches it:
- Runs entirely in-memory — zero files written to disk
- Uses the Roslyn caching pipeline — the IDE (Rider, Visual Studio) only re-runs the generator when its inputs change, eliminating background compilation loops
- Reads MSBuild properties via
AnalyzerConfigOptionsProvider— safe, no direct environment variable reads
The package auto-imports Build.props via NuGet, which declares CompilerVisibleProperty items and suppresses the SDK's default AssemblyInfo generation (preventing CS0579 duplicate attribute errors when the generator is enabled).
Diagnostics
| ID | Severity | Description |
|---|---|---|
BENNEWITZGEN00 |
Warning | Generator is installed but GenerateAutoVersionedAssemblyInfo is not set to true |
BENNEWITZGEN01 |
Warning | Generator threw an unexpected exception |
BENNEWITZGEN02 |
Error | AssemblyCompany is not configured |
BENNEWITZGEN03 |
Error | AssemblyProduct is not configured |
Building Locally
Requires PowerShell 7+ and the .NET SDK.
./Pack.ps1
The script prompts for a version (defaults to CalVer YYYY.Q.MMDD) and produces .nupkg files in packages/Debug/ and packages/Release/.
License
MIT © 2026 Brian Bennewitz
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.4.1202 | 48 | 12/3/2026 |
| 2026.4.1124 | 215 | 11/24/2026 |
| 2026.4.1116 | 623 | 11/16/2026 |
| 2026.4.1031 | 3,463 | 10/31/2026 |
| 2026.3.928 | 820 | 9/28/2026 |
| 2026.3.916 | 6,981 | 9/16/2026 |
| 2026.3.914 | 1,738 | 9/14/2026 |
| 2026.3.819 | 2,188 | 8/19/2026 |
| 2026.3.701 | 18,435 | 7/1/2026 |
| 2026.2.522 | 829 | 5/21/2026 |
| 2026.2.521 | 144 | 5/21/2026 |
| 2026.2.515 | 146 | 5/15/2026 |
| 2026.2.501 | 195 | 5/1/2026 |
| 2026.2.429 | 190 | 4/29/2026 |