XperienceCommunity.AppSettingsJsonRegistration 1.0.1

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

// Install XperienceCommunity.AppSettingsJsonRegistration as a Cake Tool
#tool nuget:?package=XperienceCommunity.AppSettingsJsonRegistration&version=1.0.1

Xperience appsettings.json Registration

GitHub Actions CI: Build

Publish Packages to NuGet

NuGet Package

This package provides a Kentico Xperience 13.0 custom module to auto-register the ASPNET Core appsettings.json as Xperience's configuration source.

This is useful in Console applications which do not use an IHostBuilder to configure the application.

Dependencies

This package is compatible with ASP.NET Core 3.1 → ASP.NET Core 5 and is designed to be used with .NET Core / .NET 5 Console applications integrated with Kentico Xperience 13.0.

How to Use?

  1. First, install the NuGet package in your ASP.NET Core project

    dotnet add package XperienceCommunity.AppSettingsJsonRegistration
    
  2. Create an appsettings.json file at the root of your console app project with the CMSConnectionString

    {
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
      "ConnectionStrings": {
        "CMSConnectionString": "<your connection string here>"
      }
    }
    
  3. Ensure the appsettings.json file is configured to copy to the output directory on build by editing your console application's .csproj file and adding the following (if it doesn't already exist)

    <ItemGroup>
         <None Update="appsettings.json">
             <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
         </None>
    </ItemGroup>
    
  4. Add the call to CMSApplication.Init(); at the beginning of your Main() method

    class Program
    {
        static void Main(string[] args)
        {
            CMSApplication.Init();
    
            // ...
        }
    }
    

This package also supports having a appsettings.local.json which is optional and can be ignored in your source control.

It can also support User Secrets. First add the package to your application:

<ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.11" />
</ItemGroup>

Then right click on your project in Visual Studio and select "Manage User Secrets" to create the secrets file.

Secrets can also be managed for a project, outside of Visual Studio, at the commend line using the .NET CLI.

Contributions

If you discover a problem, please open an issue.

If you would like contribute to the code or documentation, please open a pull request.

References

Kentico Xperience

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
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
1.0.1 2,436 4/3/2022
1.0.1-prerelease-9-1 587 4/3/2022
1.0.1-prerelease-2086189913-8 591 4/3/2022
1.0.1-prerelease-2086137420-6 636 4/3/2022
1.0.0 1,142 10/20/2021