Dotenv.Extensions.Microsoft.Configuration
3.1.0
dotnet add package Dotenv.Extensions.Microsoft.Configuration --version 3.1.0
NuGet\Install-Package Dotenv.Extensions.Microsoft.Configuration -Version 3.1.0
<PackageReference Include="Dotenv.Extensions.Microsoft.Configuration" Version="3.1.0" />
paket add Dotenv.Extensions.Microsoft.Configuration --version 3.1.0
#r "nuget: Dotenv.Extensions.Microsoft.Configuration, 3.1.0"
// Install Dotenv.Extensions.Microsoft.Configuration as a Cake Addin #addin nuget:?package=Dotenv.Extensions.Microsoft.Configuration&version=3.1.0 // Install Dotenv.Extensions.Microsoft.Configuration as a Cake Tool #tool nuget:?package=Dotenv.Extensions.Microsoft.Configuration&version=3.1.0
Dotenv.Extensions.Microsoft.Configuration
ENV configuration provider implementation for Microsoft.Extensions.Configuration.
This library adds extension methods for the Microsoft.Extensions.Configuration package, which can be accessed through the IConfigurationBuilder interface. So, this library is just a wrapper and behind the scenes what happens is that it uses the classes and methods from the DotEnv.Core project.
This project was created to integrate the DotEnv.Core package into the .NET configuration system.
Refer to the API documentation.
Installation
If you're want to install the package from Visual Studio, you must open the project/solution in Visual Studio, and open the console using the Tools > NuGet Package Manager > Package Manager Console command and run the install command:
Install-Package Dotenv.Extensions.Microsoft.Configuration
If you are making use of the dotnet CLI, then run the following in your terminal:
dotnet add package Dotenv.Extensions.Microsoft.Configuration
Usage
The following example shows how to read the application configuration from ENV file.
using System;
using Microsoft.Extensions.Configuration;
class Program
{
static void Main()
{
// Build a configuration object from ENV file.
IConfiguration config = new ConfigurationBuilder()
.AddEnvFile("appsettings.env", optional: true)
.Build();
// Get a configuration section.
IConfigurationSection section = config.GetSection("Settings");
// Read configuration values.
Console.WriteLine($"Server: {section["Server"]}");
Console.WriteLine($"Database: {section["Database"]}");
}
}
To run this example, include an appsettings.env
file with the following content in your project:
Settings__Server=example.com
Settings__Database=Northwind
It doesn't matter if your .env file is in the root directory of your project, the configuration provider will start searching from the current directory and go up the parent directories until it finds it.
Samples
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- DotEnv.Core (>= 3.1.0)
- Microsoft.Extensions.Configuration (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.1.0 | 726 | 6/29/2024 |