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
<PackageReference Include="Dirk-Jan.AspNetCore.VersionInformation" Version="1.0.0" />
<PackageVersion Include="Dirk-Jan.AspNetCore.VersionInformation" Version="1.0.0" />
<PackageReference Include="Dirk-Jan.AspNetCore.VersionInformation" />
paket add Dirk-Jan.AspNetCore.VersionInformation --version 1.0.0
#r "nuget: Dirk-Jan.AspNetCore.VersionInformation, 1.0.0"
#:package Dirk-Jan.AspNetCore.VersionInformation@1.0.0
#addin nuget:?package=Dirk-Jan.AspNetCore.VersionInformation&version=1.0.0
#tool nuget:?package=Dirk-Jan.AspNetCore.VersionInformation&version=1.0.0
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 | Versions 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. |
-
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 |