Getting started with Esquio in .NET Core

In this article, we are going to see how easy it is to use Esquio in your .NET Core application using the NuGet packages provided by Xabaril.

> In samples/GettingStarted.ConsoleApp you’ll find a complete Esquio example in ASP.NET Core.

Create a folder for your new project

Open a command prompt an run:

mkdir consoleapp
cd consoleapp

Create the project

To create the project type the following command using the .NET Core CLI:

dotnet new console


To install Esquio type the following command:

dotnet package add Microsoft.Extensions.DependencyInjection
dotnet package add Microsoft.Extensions.Logging.Console
dotnet package add Microsoft.Extensions.Configuration.Json
dotnet package add Esquio.Configuration.Store
dotnet restore

or using Powershell or Package Manager:

Install-Package Microsoft.Extensions.DependencyInjection
Install-Package Microsoft.Extensions.Logging.Console
Install-Package Microsoft.Extensions.Configuration.Json
Install-Package Esquio.Configuration.Store


In the Program.cs, change the Main method to async:

static async Task Main(string[] args)

Import the configuration namespace:

using Microsoft.Extensions.Configuration;

Create the configuration object:

var configuration = new ConfigurationBuilder()

Add a appsettings.json file to the project and add the content below:

  "Esquio": {
    "Products": [
        "Name": "Console",
        "Features": [
            "Name": "Colored",
            "Enabled": true,
            "Toggles": []

Register the Esquio services and the configuration store:

var services = new ServiceCollection()
  .AddLogging(configure => configure.AddConsole())
  .AddConfigurationStore(configuration, "Esquio")

Build the service provider:

var serviceProvider = services.BuildServiceProvider();

Obtain a context for the IFeatureService:

var featureService = serviceProvider.GetService<IFeatureService>();

Check if “Colored” feature for the “Console” project is enabled and set the background color of the console to blue:

if (await featureService.IsEnabledAsync("Colored"))
  Console.BackgroundColor = ConsoleColor.Blue;

Finally, write a message to check it:

Console.WriteLine("Welcome to Esquio!");

Test the application

Test the app on your computer running:

dotnet run

To disable the feature, change the appsettings.json:

"Enabled": false

And test again the app: