Bennewitz.Ninja.AutoVersioning.Abstractions 2026.4.1124

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Bennewitz.Ninja.AutoVersioning.Abstractions --version 2026.4.1124
                    
NuGet\Install-Package Bennewitz.Ninja.AutoVersioning.Abstractions -Version 2026.4.1124
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bennewitz.Ninja.AutoVersioning.Abstractions" Version="2026.4.1124" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bennewitz.Ninja.AutoVersioning.Abstractions" Version="2026.4.1124" />
                    
Directory.Packages.props
<PackageReference Include="Bennewitz.Ninja.AutoVersioning.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bennewitz.Ninja.AutoVersioning.Abstractions --version 2026.4.1124
                    
#r "nuget: Bennewitz.Ninja.AutoVersioning.Abstractions, 2026.4.1124"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bennewitz.Ninja.AutoVersioning.Abstractions@2026.4.1124
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bennewitz.Ninja.AutoVersioning.Abstractions&version=2026.4.1124
                    
Install as a Cake Addin
#tool nuget:?package=Bennewitz.Ninja.AutoVersioning.Abstractions&version=2026.4.1124
                    
Install as a Cake Tool

Bennewitz.Ninja.AutoVersioning.Abstractions

Read a Bennewitz.Ninja.AutoVersioning CalVer stamp back off a built assembly.

Bennewitz.Ninja.AutoVersioning stamps your assemblies with a version of the form YEAR.QUARTER.MMdd.HHmm. It ships as a Roslyn analyzer, so your compiler loads it and your code never sees it. This package is the small library that lets your code — a test, a diagnostic, a support endpoint — turn one of those versions back into the moment it was stamped.

It is useful on its own, but it exists for one job in particular: asserting in your own tests that a built artifact carries the stamp this build gave it.

Install

dotnet add package Bennewitz.Ninja.AutoVersioning.Abstractions

Targets netstandard2.0, so it works from .NET Framework 4.6.1 onward and on every modern .NET. It has no dependencies, and it does not require Bennewitz.Ninja.AutoVersioning to be installed — though reading a stamp back is of limited use if nothing is stamping it.

Use

using Bennewitz.Ninja.AutoVersioning;

var assembly = new FileInfo(typeof(Thing).Assembly.Location);

if (BuildVersion.TryGetFromFile(assembly, out var version))
{
    Console.WriteLine(version!.Version);       // 2026.4.1119.1613
    Console.WriteLine(version.BuildDateTime);  // 2026-11-19 16:13 +00:00
    Console.WriteLine(version.BuildTime);      // culture-invariant, safe to embed
}

TryGetFromFile returns false rather than throwing for a version it does not recognise — an unstamped 1.0.0.0, or a month of 13 — so it is safe to call on any assembly.

In a test

[TestMethod]
public void TheBuiltAssembly_CarriesThisBuildsStamp()
{
    var assembly = new FileInfo(typeof(Thing).Assembly.Location);

    Assert.IsTrue(BuildVersion.TryGetFromFile(assembly, out var version));
    Assert.AreEqual(DateTimeOffset.Now.Date, version!.BuildDateTime.Date);
}

What the four parts mean

Part Meaning Example
YEAR The calendar year 2026
QUARTER (month + 2) / 3 4
MMdd Month and day, as an integer — leading zeros are gone, so 5 January is 105 1119
HHmm Hour and minute, likewise: 08:45 is 845, and 00:05 is 5 1613

Because MMdd and HHmm are stored as integers, a stamp is decomposed arithmetically rather than by parsing the version string.

Two behaviours worth knowing

A three-part version reads as midnight. FileVersionInfo reports an absent fourth part as 0, and this package always stamps four, so 2026.4.1119 and 2026.4.1119.0000 are indistinguishable.

A Debug build's stamp is midnight on purpose. Since 2026.4.1116, a Debug build holds its BuildTimestamp to its day, so that repeated Debug builds stop recompiling every project. Such a stamp reads back as 00:00:00 that day — faithfully the stamp, which is not the instant the build ran. See docs/MultiProjectBuildTimestamps.md, which also measures what a clock-stamped build does across a large solution.

Comparing two stamps

FuzzyBuildVersionComparer calls two versions equal when everything but the revision matches and the revisions are within a tolerance. Default is 30 minutes:

if (FuzzyBuildVersionComparer.Default.Equals(mine, theirs))
{
    // same build, near enough
}

var strict = new FuzzyBuildVersionComparer(TimeSpan.FromMinutes(2));

It decodes HHmm before comparing, so 09:59 and 10:00 are one minute apart rather than the 41 their raw integers suggest.

⚠ The relation is not transitive, as no tolerance-based equality is: with a 3-minute tolerance 10:00 equals 10:03 and 10:03 equals 10:06, but 10:00 does not equal 10:06. So do not deduplicate by sorting and comparing neighbours, and do not expect a HashSet to group what you meant — GetHashCode leaves the revision out, which is the only contract a hash can keep under a relation like this.

MIT licensed.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • 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 46 12/3/2026
2026.4.1124 109 11/24/2026