Antyrama.Tools.Scribe.Cli 0.0.15-rc

This is a prerelease version of Antyrama.Tools.Scribe.Cli.
There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global Antyrama.Tools.Scribe.Cli --version 0.0.15-rc                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local Antyrama.Tools.Scribe.Cli --version 0.0.15-rc                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Antyrama.Tools.Scribe.Cli&version=0.0.15-rc&prerelease                
nuke :add-package Antyrama.Tools.Scribe.Cli --version 0.0.15-rc                

Settings Scrapper Tool

Build Status NuGet Nuget

A smart CLI tool that automates the tedious task of configuring application services in the cloud.

What it does?

Once executed, tool will hook up to host of Microsoft.NET.Sdk.Web application, collect all application settings and update your configuration JSON or YAML file.

Getting started

Tool can be installed using the Nuget package manager or the dotnet CLI.

1. Create tool manifest

Open you web application project folder in terminal and run the following

dotnet new tool-manifest

2. Install tool

Install Antyrama.Tools.Scribe.Cli tool package into your project

dotnet tool install Antyrama.Tools.Scribe.Cli

3. Install core library

Install Antyrama.Tools.Scribe.Core package into your project

dotnet add package Antyrama.Tools.Scribe.Core

4. Configure project

For full automation, add below entry in .csproj file. Configuration files will be generated/updated after each build.

  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="dotnet restore" />
    <Exec Command="dotnet tool restore" />
    <Exec Command="dotnet tool run app-settings-to-file generate --assembly $(OutputPath)\$(AssemblyName).dll " />
  </Target>

5. Final touches

According to the Microsoft documentation, the SDK uses the latest version that is installed:

The .NET CLI must choose an SDK version for every dotnet command. It uses the latest SDK installed on the machine by default, even if the project targets an earlier version of the .NET runtime.

If latest version of your installed SDK is higher than your project target framework, add anywhere in your project hierarchy global.json file with below content:

{
  "sdk": {
    "version": "6.0.0",
    "rollForward": "latestFeature"
  }
}

6. Build your project

The first time you build your project, configuration file(s) will be created. Changes made to your values in appSettings.json file, after the next build will not affect previous values in generated file. New appSettings.json entries and changes to the structure will create or remove entries in generated configuration files.

Advanced configuration

Tool is customisable, take a look at list of all arguments that can be passed. Each time when a list type of give option is mentioned, you separate items using space.

Short name Full name Is optional Description Default value
-a --assembly Startup assembly file path and name. Can be obtained by $(OutputPath)\$(AssemblyName).dll
-p --providers ✔️ A list of configuration providers from which all setting keys are taken. All types derived from IConfigurationProvider JsonConfigurationProvider
-i --include ✔️ A list of keys to include despite of providers list configuration. Example: PROCESSOR_ARCHITECTURE
-x --exclude ✔️ A list of keys to exclude from all collected settings. Example: Logging:LogLevel:Microsoft.AspNetCore
-s --separator ✔️ Setting nesting separator __ (double underscore)
-v ‑‑yaml‑variable‑name ✔️ YAML variable name app_config
-y --to-yaml ✔️ Indicates whether configuration wrapped in YAML Azure DevOps variables file false
-f --file-path-template ✔️ File name template for output. Template may contain a placeholder for environment name. Example: configuration.{0}.json ./configuration.json
-e --environments ✔️ A list of environment names. Separate configuration file will be created per each environment. Required when file name template contains placeholder
-l -eol ✔️ Customize end-of-line characters, possible values: Cr, CrLf or Lf, when skipped, operating system default end-of-line characters will be used

Configuration providers

If you'd like to include all the settings collected by different configuration provider, add them all by --providers option. More information about configuration providers.

YAML v.s. JSON

You may want to keep you your service configuration in JSON and then load it in your pipeline to configure service. If you use option --to-yaml, then JSON content will be wrapped in YAML, issuing a variable with your JSON, like on the below example.

# File: configuration.yaml
variables:
  app_config: |-
    [
      {"name": "AllowedHosts", "value": "*", "slotSetting": false},
      {"name": "Logging__LogLevel__Default", "value": "Information", "slotSetting": false},
      {"name": "Logging__LogLevel__Microsoft.AspNetCore", "value": "Warning", "slotSetting": false}
    ]

Then you can easily use it in your pipeline

# File: azure-pipeline.yaml
variables:
  - template: configuration.yaml  # Template reference

steps:
  - step ...

Where are my files?

By default, the configuration file(s) are placed in the same directory as your .csproj. Depending on the folder structure of your solution you may want to place the files elsewhere. To do this, set option --file-path-template to desired value. The option allows you to pass relative paths, e.g. ../../configuration.yaml

Multiple environment setup

Tool is able to create one configuration file per environment. Set option --environments to dev test prod and --file-path-template to ./configuration.{0}.yaml, will create three files

configuration.dev.yaml 
configuration.prod.yaml
configuration.test.yaml
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 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.

This package has no dependencies.

Version Downloads Last updated
0.0.16-rc 60 10/28/2024
0.0.15 1,127 4/6/2024
0.0.15-rc 222 4/6/2024
0.0.14-rc 271 3/30/2024 0.0.14-rc is deprecated because it has critical bugs.
0.0.13-rc 315 3/30/2024 0.0.13-rc is deprecated because it has critical bugs.
0.0.12 675 3/26/2024
0.0.12-rc 284 3/26/2024
0.0.11-rc 331 3/26/2024
0.0.10-rc 233 3/26/2024
0.0.9 1,223 1/11/2024
0.0.8 2,538 9/27/2023
0.0.8-rc 1,638 9/27/2023
0.0.7 1,988 9/25/2023
0.0.6 1,797 9/25/2023
0.0.5 2,291 7/30/2023
0.0.5-rc 2,100 7/30/2023
0.0.4-rc 2,402 4/1/2023
0.0.3-rc 2,242 4/1/2023