mu88.Shared 0.4.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package mu88.Shared --version 0.4.0                
NuGet\Install-Package mu88.Shared -Version 0.4.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="mu88.Shared" Version="0.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add mu88.Shared --version 0.4.0                
#r "nuget: mu88.Shared, 0.4.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 mu88.Shared as a Cake Addin
#addin nuget:?package=mu88.Shared&version=0.4.0

// Install mu88.Shared as a Cake Tool
#tool nuget:?package=mu88.Shared&version=0.4.0                

mu88.Shared

Combine CI / Release NuGet version NuGet downloads  
Reliability Rating Security Rating Maintainability Rating Bugs Vulnerabilities Code Smells Coverage

General

This repo contains the code of the NuGet package mu88.Shared, providing the following features:

I use this NuGet package to share features and configurations between different .NET apps, hence avoiding the need to implement it repeatedly.

Functionality details

OpenTelemetry

By calling the extension method ConfigureOpenTelemetry on an instance of Microsoft.Extensions.Hosting.IHostApplicationBuilder, the following OpenTelemetry features will be enabled:

  • Metrics   - ASP.NET Core (e.g. request duration) → see here   - .NET process information (e.g. process memory) → see here   - .NET runtime information (e.g. GC heap size) → see here
  • Tracing   - ASP.NET Core → see here   - Entity Framework Core → see here

To export these data, the .NET configuration parameter OTEL_EXPORTER_OTLP_ENDPOINT for the OpenTelemetry endpoint receiving the exported metrics and traces must be configured, e.g. via an environment variable. See the official OpenTelemetry docs for more information.

Multi-platform Docker image

With .NET 8, the support for building Docker images without Dockerfiles has been integrated into the .NET SDK. However, it is not (yet 🫰🏻) possible to build multi-platform Docker images, i.e. a single Docker image built with the .NET SDK Container Building Tools can one target a single platform (e.g. either arm64 or x64).   The GitHub issue "Design multi-manifest (aka multi-architecture or multi-RID) publishing" tracks the process of adding this functionality to the .NET SDK. Furthermore, it also contains a very first draft of MSBuild logic on how it could work (kudos to the user baronfel). As it's quite a lot of lines, I integrated it into this NuGet package and therefore can reuse it easily.

Usage

By installing the NuGet package, the MSBuild project mu88.Shared.targets will be added to the .NET project (see here) and the target MultiArchPublish will become available which can be called like this:

dotnet publish MyProject.csproj /t:MultiArchPublish '-p:ContainerImageTags="dev"' '-p:RuntimeIdentifiers="linux-amd64;linux-arm64"' -p:ContainerRegistry=registry.hub.docker.com

This command will do the following:

  • Build the .NET project MyProject.csproj for both arm64 and amd64 targeting Linux.
  • Build and publish a Docker image per platform to the official Docker registry, i.e. there you will see two tags dev-arm64 and dev-amd64.
  • Publish a Docker image with tag dev using a new Docker manifest combining both dev-arm64 and dev-amd64.

The detour of pushing two platform-specific Docker images to the registry first and combining it afterward into a multi-platform image is a limitation of the current approach.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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
0.5.1 190 10/5/2024
0.5.0 202 8/7/2024
0.4.0 49 8/5/2024
0.3.0 41 8/3/2024
0.2.2 45 8/3/2024
0.2.1 55 8/2/2024
0.2.0 50 8/2/2024
0.1.2 54 8/2/2024
0.1.1 46 8/2/2024
0.0.8 50 8/2/2024
0.0.7 50 8/2/2024
0.0.6 48 8/2/2024
0.0.5 52 8/2/2024
0.0.4 48 8/2/2024