Dirk-Jan.AspNetCore.VersionInformation 1.0.0

dotnet add package Dirk-Jan.AspNetCore.VersionInformation --version 1.0.0
                    
NuGet\Install-Package Dirk-Jan.AspNetCore.VersionInformation -Version 1.0.0
                    
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="Dirk-Jan.AspNetCore.VersionInformation" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dirk-Jan.AspNetCore.VersionInformation" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Dirk-Jan.AspNetCore.VersionInformation" />
                    
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 Dirk-Jan.AspNetCore.VersionInformation --version 1.0.0
                    
#r "nuget: Dirk-Jan.AspNetCore.VersionInformation, 1.0.0"
                    
#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 Dirk-Jan.AspNetCore.VersionInformation@1.0.0
                    
#: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=Dirk-Jan.AspNetCore.VersionInformation&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Dirk-Jan.AspNetCore.VersionInformation&version=1.0.0
                    
Install as a Cake Tool

AspNetCore.VersionInformation

Small library providing version endpoint and version logging compatible with GitVersion.

It tries to read the version information from the InformationalVersion attribute in the project file. If no SemVer can be parsed from the InformationalVersion attribute value, it will fall back to the assembly version.

Repository: Dirk-Jan/AspNetCore.VersionInformation (GitHub.com)

Package: Dirk-Jan.AspNetCore.VersionInformation (NuGet.org)

Getting Started

Installation

Add the version information service to your dependency injection container in Program.cs:

using DirkJan.AspNetCore.VersionInformation;

var builder = WebApplicationBuilder.CreateBuilder(args);

builder.Services.AddVersionInformation();

var app = builder.Build();

Getting Version Information

Via HTTP Endpoint

Map the version information endpoint to expose version data via HTTP:

var app = builder.Build();

app.MapVersionInformation(); // Maps to /version by default

app.Run();

You can customize the endpoint path:

app.MapVersionInformation("/api/version");

The endpoint returns JSON with version details:

{
  "name": "MyApp",
  "semVer": "1.2.3-beta",
  "majorMinorPatch": "1.2.3",
  "major": 1,
  "minor": 2,
  "patch": 3,
  "preReleaseTag": "beta",
  "sha": "abc1234567890def1234567890def1234567890",
  "shortSha": "abc1234",
  "branch": "main",
  "assemblyVersion": "1.2.3.0",
  "informationalVersion": "1.2.3-beta+branch.main.sha.abc1234567890def1234567890def1234567890"
}
Via Logging

Log the version information when the application starts:

var app = builder.Build();

app.LogVersion(); // Uses default log level (Information)

app.Run();

You can customize the log level:

app.LogVersion(LogLevel.Debug);

Or extract a custom version string:

app.LogVersion(LogLevel.Information, info => info.SemVer);

By default it logs SemVer, falling back to InformationalVersion or AssemblyVersion.

Programmatic Access

Inject and use IVersionInformationService in your code:

public class MyController(IVersionInformationService versionService) : ControllerBase
{
    [HttpGet("my-version")]
    public VersionInfo GetVersion()
    {
        return versionService.GetVersionInformation();
    }
}
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.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
1.0.0 127 7/8/2026
0.0.1-alpha 119 7/5/2026