UoN.AspNetCore.VersionMiddleware 2.0.0

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

// Install UoN.AspNetCore.VersionMiddleware as a Cake Tool
#tool nuget:?package=UoN.AspNetCore.VersionMiddleware&version=2.0.0                

UoN.AspNetCore.VersionMiddleware

Build Status NuGet Badge MIT License Badge

What is it?

This is middleware for ASP.Net Core designed to report on version information related to your project.

We use it at UoN so that we can check the version of a web app wherever it's deployed, without having to display it publicly to users who don't care. This is useful for ensuring testers know which builds they're working with and therefore what fixes to test.

What are its features?

It exposes the version output of UoN.VersionInformation as JSON data at an http endpoint.

Middleware Extension Methods

Endpoint Routing

It provides four IEndpointRouteBuilder Extension methods for you to use in Startup.Configure():

  • app.MapUonVersionInformation()
    • adds a /version endpoint to the ASP.Net Core pipeline.
    • returns AssemblyInformationalVersion for the Application's Entry Assembly.
  • app.MapUonVersionInformation(path)
    • behaves as above but with a custom route path
  • app.MapUonVersionInformation(source)
    • adds a /version endpoint to the ASP.Net Core pipeline.
    • expects a valid source accepted by VersionInformationService
  • app.MapUonVersionInformation(path, source)
    • behaves as above but with a custom route path
Terminal Middleware

[!NOTE] Prefer Endpoint routing above unless you know you need Terminal Middleware

It provides two traditional "Terminal Middleware" IApplicationBuilder Extension methods for you to use in Startup.Configure():

  • app.UseUonVersionInformation(source)
  • app.UseUonVersionInformation(path, source)
    • behaves as above but with a custom route path

Dependencies

The library targets net5.0 and depends upon the ASP.NET Core app framework package and UoN.VersionInformation.

If you can use ASP.NET Core 5.x or newer, you can use this library.

Example usage

Startup.cs
public class Startup
{
  // ...

  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
    // ...

    app.UseStaticFiles();

    app.UseRouting();

    app.MapUonVersionInformation(); //adds `/version` endpoint
  }
}

Refer to the samples for additional usage examples.

Building from source

We recommend building with the dotnet cli, but since the package targets net5.0 and depends only on ASP.Net Core, you should be able to build it in any tooling that supports those requirements.

  • Have the .NET Core SDK 5.0 or newer
  • dotnet build
  • Optionally dotnet pack
  • Reference the resulting assembly, or NuGet package.

Contributing

Contributions are unlikely to be needed often as this is a library with a very specific purpose.

If there are issues open, please feel free to make pull requests for them, and they will be reviewed.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
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
2.0.0 434 5/22/2024
1.1.1 9,959 5/9/2018
1.1.0 986 5/2/2018
1.0.0 920 11/10/2017

## Enhancements

- Added Endpoint routing support and EndpointRouteBuilder extensions

## Technical changes

- Extension methods (both ApplicationBuilder and EndpointRouteBuilder) are now in the `Microsoft.AspNetCore.Builder` namespace
- Extension method names have changed (primarily adding the `Uon` prefix) to avoid potential collisions in the Microsoft namespace
- The dependency on `Newtonsoft.Json` has been removed in favour of the built-in `System.Text.Json`.
- Minimum target is now .NET5
   - Technically this package could probably still be more broadly usable than that, but it is explicitly for ASP.NET Core, so targeting minimum unified .NET made sense.

## Fixes
- Since .NET8 the middleware was crashing due to the `Newtonsoft.Json` dependency, without further configuration. Removal of that dependency resolves this issue and retains "zero-config"