In .net Core 1 we could do this:
IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build();
And that gave use the Configuration object that we could then use in our console app.
All examples for .net core 2.0 seem to be tailored to the new way Asp.Net core config is created.
What is the way to create configurations for console apps?
Update: this question is not related to Asp.net core. Please do not add asp.net core tags when editing.
In . NET Core, it runs from the dll, so you have to just run the application by running the command prompt and using the command - dotnet run. Open your command prompt and go to that folder where your application persists.
Application configuration in ASP.NET Core is performed using one or more configuration providers. Configuration providers read configuration data from key-value pairs using a variety of configuration sources: Settings files, such as appsettings. json.
It seems there is no change, as Jehof says.
ConfigurationBuilder is in its own package, as Jeroen Mostert says.
But make sure you also have the Microsoft.Extensions.Configuration.Json package, where the .AddJsonFile() extension lives.
In summary, you need the following two NuGet packages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With