Answers for "use appsettings.json in console app"

0

appsettings in console application c#

public Startup()
{
    var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

        configuration = new ConfigurationBuilder()
                        .SetBasePath(Directory.GetCurrentDirectory())
                        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                        .AddJsonFile($"appsettings.{environment}.json", optional: true)
                        .AddEnvironmentVariables()
                        .Build();
}
Posted by: Guest on May-22-2020
2

use appsettings.json in console app

All that’s required is to add the following NuGet packages and an appsettings.json file.

Microsoft.Extensions.Configuration
Microsoft.Extensions.Configuration.FileExtensions
Microsoft.Extensions.Configuration.Json

The appsettings.json files “Copy to Output Directory” property should also be set to “Copy if newer” so that the application is able to access it when published.
Posted by: Guest on March-10-2020

Code answers related to "use appsettings.json in console app"

Code answers related to "Javascript"

Browse Popular Code Answers by Language