DEV Community

Cover image for AspNetCore.VersionInfo 1.1.0 is out
Giorgio Lasala
Giorgio Lasala

Posted on

AspNetCore.VersionInfo 1.1.0 is out

AspNetCore.VersionInfo is a NuGet library that provides a simple and effective way to obtain information about the version of the running ASP.NET Core application. This library can be used for various purposes, such as displaying the version on your web application or the list of referenced assemblies.
This library targets .NET 6 and is easy to install and configure in an existing ASP.NET Web Application.

After installing the NuGet package, it is sufficient to add the VersionInfo middleware to the application's middleware pipeline in the Configure and ConfigureServices method of the Startup object:

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();
        });
    }
}
Enter fullscreen mode Exit fullscreen mode

Once configured, the library will provide information about the application version through different endpoints; in particular there are 3 endpoints:

  • /version/json -> will return a JSON object
  • /version/html -> will return an HTML user-friendly page
  • /version/badge -> a nice and highly configurable badge image

Using this library has several advantages over manually implementing the application version. Firstly, the library provides a standardized way of obtaining information about the application version with a few lines of code, using built-in providers.

Additionally, the library provides a high level of configurability, allowing for customization of both the collected information and UI visualization (such as badge color and icons).

More information and samples are available on GitHub repository.

I'd love to know what your opinion!

Top comments (0)