Re:Is ASP.NET Core Now a Mature Platform?
by openbasic on Wednesday December 19, 2018 @09:56AM
(#18715960)
The whole environment handling bothers me, specially when working with containers. Why can't we have something normal like a .env?
[ Parent
| on HN ]
Re:Is ASP.NET Core Now a Mature Platform?
by tracker1 on Wednesday December 19, 2018 @03:52PM
(#18719484)
There's a couple dotenv nuget packages...
using DotEnv = dotenv.net.DotEnv;
But I wish the usage for the default load scenario was better. Here's how I'm using it. public static void Init()
{
var levelsToCheck = 4;
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
for (; currentDirectory != null && levelsToCheck > 0; levelsToCheck--, currentDirectory = currentDirectory.Parent)
{
foreach (var fi in currentDirectory.GetFiles(".env", SearchOption.TopDirectoryOnly))
{
DotEnv.Config(false, fi.FullName);
return; // found .env file
}
};
}