I have a class library i want end up packaging into a nuget package, i have some configurations i wish to use which are in a json
file (apsettings.json
).
I have added this file to my class library project, and at the moment i just want to read the values in the configurations in a constructor without using a .config
file, i will like to use a .json
similar to how i'll do it in a web project.
I am trying something like this, but i get an error stating that the settings.json file does not exist in \bin\Debug\netcoreapp2.0
. It is not in that folder, it is in the root of my project.
public TokenGenerator()
{
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("settings.json");
_configuration = builder.Build();
_tokenServiceSettings = new TokenServiceSettings()
{
Audience = _configuration.GetSection("JwtBearer:Audience").Value
};
}
At the moment, i have just hard coded the directory as a string inside the SetBasePath method