Total Downloads
808
808
Published
May 12, 2024
2y ago
Get Started
dotnet add package Narochno.EnvFile --version 1.1.0
| Product | Versions |
|---|---|
| .NET |
README
Narochno.EnvFile
Inspired by https://github.com/motdotla/dotenv
This will load .env files into IConfiguration (instead of Environment Variables like dotenv) to be used by .NET Core applications.
Usage
Just like other configuration providers. Recommended to load ENV VARs for your 12 factor apps after attempting to load from the local file.
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
var configuration = new ConfigurationBuilder()
// can overload to have other file names than .env
.AddEnvFile()
// overwrite env file vars
.AddEnvironmentVariables()
.Build();
return new WebHostBuilder()
.UseStartup<Startup>()
.UseKestrel()
.UseUrls(configuration.GetValue<string>("HOST"))
.ConfigureLogging(lb => { lb.AddConsole(); })
.UseConfiguration(configuration);
}
}
Downloads by Version
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.