AspNetCore.VersionInfo 1.1.0

dotnet add package AspNetCore.VersionInfo --version 1.1.0
NuGet\Install-Package AspNetCore.VersionInfo -Version 1.1.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="AspNetCore.VersionInfo" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNetCore.VersionInfo --version 1.1.0
#r "nuget: AspNetCore.VersionInfo, 1.1.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.
// Install AspNetCore.VersionInfo as a Cake Addin
#addin nuget:?package=AspNetCore.VersionInfo&version=1.1.0

// Install AspNetCore.VersionInfo as a Cake Tool
#tool nuget:?package=AspNetCore.VersionInfo&version=1.1.0

NuGet version .NET License Coverage Security Rating Reliability Rating

AspNetCore.VersionInfo

AspNetCore.VersionInfo is a library to expose information about assembly versions used in your web application. In particular there are two endpoints, which returns:

  • a JSON-formatted data (/version/json)
  • an HTML user-friendly page (/version/html)
  • a nice badge image (/version/badge)

Library offers some in-bundle providers to capture versions information, such as the version of entry assembly or the version of the common language runtime. A typical JSON output is:

{
    "RuntimeInformation.FrameworkDescription":".NET 6.0.8",
    "EntryAssemblyVersion":"2.5.0.0",

    ...
}

Moreover it is possible create a specific class to collect additional data as described in Providers section.

Prerequisites

This library currently targets net6.0

Download

Prerelease packages are on GH Packages

Release packages are on Nuget

Demo

URL
Win Windows Web App https://aspnetcoreversioninfo-demo.azurewebsites.net
Win Windows HTML Endpoint /version/html
Win Windows JSON Endpoint /version/json
Win Windows Badge Endpoint /version/badge
Linux Linux Web App https://aspnetcoreversioninfo-linux-demo.azurewebsites.net
Linux Linux HTML Endpoint /version/html
Linux Linux JSON Endpoint /version/json
Linux Linux Badge Endpoint /version/badge

Getting Started

Startup.cs

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddVersionInfo()
            .With<ClrVersionProvider>()
            .With<AssemblyVersionProvider>();
    }

    public void Configure(IApplicationBuilder app)
    {
        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapVersionInfo();
        });
    }
}

Providers

Library is based on following types:

  • Providers, that read information and return data in a dictionary
  • Collector, that aggregates all data from providers and exposes to endpoints.

A Collector implementation is already included in AspNetCore.VersionInfo package, and usually its default implementation is valid for all scenarios.

Instead, in order to enrich data gathered from library, multiple custom providers could be developed, implementing custom classes inherited from IInfoProvider interface.

To show providers' information, they have to be configured in ConfigureServices declaration, using .With<IInfoProvider> extension method.

In-bundle providers

AspNetCore.VersionInfo package includes following providers:

Provider Keys Description
AssemblyVersionProvider EntryAssembly <br/> EntryAssemblyFullName <br/> EntryAssemblyLocation <br/> EntryAssemblyDirectoryPath <br/> EntryAssemblyFileVersion <br/> EntryAssemblyClrVersion <br/> EntryAssemblyCreationDate <br/> EntryAssemblyLastModifiedDate Version and main properties of entry assembly
ClrVersionProvider RuntimeInformation.FrameworkDescription <br/> RuntimeInformation.OsDescription <br/> RuntimeInformation.OsArchitecture <br/> RuntimeInformation.ProcessArchitecture <br/> RuntimeInformation.RuntimeIdentifier Version of the common language runtime and .NET installation on which the app is running
AppDomainAssembliesVersionProvider <AssemblyName> Version of assemblies loaded in App Domain
EnvironmentProvider Environment.Uptime <br/> Environment.OSVersion <br/> Environment.IsOsWindows <br/> Environment.Is64BitOperatingSystem <br/> Environment.Is64BitProcess <br/> Environment.ProcessorCount <br/> Environment.MachineName <br/> Environment.SystemDirectory <br/> Environment.WorkingDirectory <br/> Environment.CommandLine <br/> Environment.DotNetVersion Environment properties
EnvironmentVariablesProvider <EnvironmentVariableName>-<EnvironmentVariableValue> Environment variables

Options

MapVersionInfo extension method accepts an optional VersionInfoOptions argument to change default URLs:


public void Configure(IApplicationBuilder app)
{
    app.UseRouting();

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapVersionInfo(o =>
        {
            o.HtmlPath = CUSTOM_HTML_URL;
            o.ApiPath = CUSTOM_JSON_URL;
        });
    });
}

Badge

Badge image can be obtained with url

/version/badge/{versionInfoId}

where {versionInfoId} is a key returned by providers.

Moreover endpoint accepts following parameters in querystring:

  • label: it's the name to show in the image
  • icon: the source type and slug for the icon separated by two underscore characters (__) such as simpleicons__azure. In this version only Simple Icons type is supported; you can find a list of slugs here. Icon color is always white.
  • color: a string as defined in the colors table or a custom colors in hexadecimal, RGB, HSL.
Color String
#4c1 BrightGreen
#97CA00 Green
#dfb317 Yellow
#a4a61d YellowGreen
#fe7d37 Orange
#e05d44 Red
#007ec6 Blue
#555 Gray
#9f9f9f LightGray
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 4,146 3/6/2023
1.0.0 466 10/5/2022
0.7.0 401 9/21/2021
0.6.0 369 7/1/2021
0.5.0 373 3/2/2021
0.4.0 372 2/28/2021
0.3.0 351 2/21/2021
0.2.0 340 2/21/2021
0.1.0 361 2/17/2021