Seekatar.Tools 0.2.0

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

// Install Seekatar.Tools as a Cake Tool
#tool nuget:?package=Seekatar.Tools&version=0.2.0                

Seekatar's .NET Tools

This repo contains various .NET tools for .NET 6+

.NET codecov

Install

Installing from the NuGet.org

dotnet add package Seekatar.Tools

Configuration Extension For Devs

This set of configuration extension methods adds a low-priority JSON settings file to the IConfiguration sources for sharing configuration across projects. It easier way to share configuration and secrets as opposed launchSettings.json or Visual Studio's User Secrets. By looking up the folder structure, it allows you to share configuration across projects, and avoid committing them to a repo. There are different extension methods to cover the different types of apps:

  • Console (top-level or not)
  • .NET 8 ASP.NET with Controllers
  • .NET 8 Minimal API

By default, it looks for a file named shared.appsettings.Development.json in the binaries' folder, then marches up the folder structure looking for one until it finds it. It's useful to put one of these in a higher-level folder so multiple projects can find it. For example, for client/server apps you can put the JSON file above both project folders so they can share the configuration.

Note by default it is installed as the lowest priority configuration source so higher ones like appsettings.json and the environment will override them. If you want it highest, simply call AddJsonFile(GetSharedSettingsPath()) as the last source.

Set Environment Variables -- IMPORTANT

This is a development-only feature. It will only read the file if one of these environment variables is set to 'Development'. I usually set ASPNETCORE_ENVIRONMENT at the machine level so it is always set.

  • ASPNETCORE_ENVIRONMENT="Development" (set by default for ASP.NET apps)
  • DOTNET_ENVIRONMENT="Development"
  • NETCORE_ENVIRONMENT="Development"

Using in a Console App

Usually in a console app, you control the creation of the configuration. This code puts it as the lowest priority by adding it first.

        var configuration = new ConfigurationBuilder()
                       .AddSharedDevSettings()
                       .AddJsonFile("appsettings.json", true, true)
                       .AddEnvironmentVariables()
                       .Build();

Using in ASP.NET App

In main.cs simply add InsertSharedDevSettings to add it as the lowest priority.

using Seekatar.Tools;
...

        public static void Main(string[] args)
        {
            CreateHostBuilder(args)
                .InsertSharedDevSettings()
                .Build()
                .Run();
        }

Using in ASP.NET Minimal API App

In program.cs simply add InsertSharedDevSettings to add it after creating the builder.

using Seekatar.Tools;

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.InsertSharedDevSettings();

Parameters

Each of the extension methods takes the following parameters with default values (which are passed to the JSON source):

Name Default Description
fileName shared.appsettings.Development.json Name of file to load
reloadOnChange false If true reloads the settings when the file changes

ObjectFactory

ObjectFactory discovers derived Types and allows them to be created later.

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.2.1 103 9/13/2024
0.2.0 128 8/18/2024
0.1.5 98 9/13/2024
0.1.4 3,595 8/12/2024
0.1.3 37,349 11/7/2022
0.1.3-prerelease 148 11/7/2022
0.1.2 336 11/7/2022
0.1.1 464 3/6/2022
0.1.0 458 2/15/2022