ApiFeatures.Systems.Apis 9.0.2

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

ApiFeatures.Systems.Apis

System information API module for ASP.NET Core applications.

Features

  • System version endpoint returning commit hash and branch name
  • Minimal API implementation
  • OpenAPI/Swagger support
  • Optional authorization policy support

Installation

dotnet add package ApiFeatures.Systems.Apis

Usage

Register the feature

// In Program.cs
var addSystemFeatureOptions = new AddSystemFeatureOptions();
addSystemFeatureOptions.WithSystemVersionRetrievalFactory(serviceProvider =>
{
    // Return system version information
    // You can retrieve this from configuration, git info, etc.
    return new SystemVersionDto(
        commitHash: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
        branchName: "main"
    );
});

builder.Services.AddSystemFeature(addSystemFeatureOptions);

Add endpoints

// Map endpoints
app.AddSystemEndpoints();

// Or with authorization policy
var policy = new AuthorizationPolicyBuilder()
    .RequireAuthenticatedUser()
    .Build();

app.AddSystemEndpoints(new AddSystemEndpointsOptions()
    .WithAuthorizationPolicy(() => policy));

You can retrieve and log the system version information during application startup. The SystemVersionDto is registered as a singleton in the dependency injection container and can be accessed after building the application.

// After building the app
var app = builder.Build();

// Get logger
var logger = app.Logger;

// Retrieve and print system version information
var systemVersionDto = app.Services.GetRequiredService<SystemVersionDto>();
logger.LogInformation("System Version Information:");
logger.LogInformation("Commit Hash: {CommitHash}", systemVersionDto.CommitHash);
logger.LogInformation("Branch Name: {BranchName}", systemVersionDto.BranchName);

// Continue with middleware configuration
app.Run();

Console Output Example:

[14:32:15 INF] System Version Information:
[14:32:15 INF] Commit Hash: a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
[14:32:15 INF] Branch Name: features/system-version-endpoints

Use Cases:

  • Display build information at application startup for troubleshooting
  • Log deployment version in production environments
  • Track which code version is running in each environment
  • Include in startup banner or health check endpoints
  • Audit trail for deployed versions

Best Practices:

  • Log this information early in the startup process for visibility
  • Use structured logging (as shown) for easy parsing in log aggregation tools
  • Consider logging to both console and file sinks
  • Include in application startup logs for production deployments

Complete Example

Here's a complete example showing the full integration:

using ApiFeatures.Systems.Apis.Extensions;
using ApiFeatures.Systems.Apis.Models;
using ApiFeatures.Systems.Apis.Models.Dtos;

var builder = WebApplication.CreateBuilder(args);

// Add System feature with version information
var addSystemFeatureOptions = new AddSystemFeatureOptions();
addSystemFeatureOptions.WithSystemVersionRetrievalFactory(_ =>
{
    return new SystemVersionDto(
        commitHash: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
        branchName: "features/system-version-endpoints"
    );
});

builder.Services.AddSystemFeature(addSystemFeatureOptions);

var app = builder.Build();

var logger = app.Logger;

// Add System endpoints
app.AddSystemEndpoints();

// Print system version at startup
var systemVersionDto = app.Services.GetRequiredService<SystemVersionDto>();
logger.LogInformation("System Version Information:");
logger.LogInformation("Commit Hash: {CommitHash}", systemVersionDto.CommitHash);
logger.LogInformation("Branch Name: {BranchName}", systemVersionDto.BranchName);

app.Run();

Advanced: Retrieving Git Information Dynamically

For production deployments, you might want to retrieve git information during build time:

// Using environment variables set during CI/CD
addSystemFeatureOptions.WithSystemVersionRetrievalFactory(_ =>
{
    var commitHash = Environment.GetEnvironmentVariable("GIT_COMMIT") ?? "unknown";
    var branchName = Environment.GetEnvironmentVariable("GIT_BRANCH") ?? "unknown";

    return new SystemVersionDto(
        commitHash: commitHash,
        branchName: branchName
    );
});
// Using configuration
addSystemFeatureOptions.WithSystemVersionRetrievalFactory(serviceProvider =>
{
    var configuration = serviceProvider.GetRequiredService<IConfiguration>();
    var commitHash = configuration["SystemVersion:CommitHash"] ?? "unknown";
    var branchName = configuration["SystemVersion:BranchName"] ?? "unknown";

    return new SystemVersionDto(
        commitHash: commitHash,
        branchName: branchName
    );
});

API Endpoints

Get System Version

GET /api/system/version

Response:

{
  "commitHash": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
  "branchName": "features/system-version-endpoints"
}

License

Proprietary

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.

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
9.0.2 34 5/7/2026