22
33[ ![ CI - Build, Test & Coverage] ( https://github.com/bolorundurowb/dotenv.net/actions/workflows/build.yml/badge.svg )] ( https://github.com/bolorundurowb/dotenv.net/actions/workflows/build.yml )
44[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( LICENSE )
5- [ ![ Coverage Status ] ( https://coveralls .io/repos/github/ bolorundurowb/dotenv.net/badge.svg?branch=master )] ( https://coveralls .io/github /bolorundurowb/dotenv.net?branch=master )
5+ [ ![ codecov ] ( https://codecov .io/gh/ bolorundurowb/dotenv.net/graph/ badge.svg?token=Qw8xSiEHNp )] ( https://codecov .io/gh /bolorundurowb/dotenv.net )
66![ NuGet Version] ( https://img.shields.io/nuget/v/dotenv.net )
77
88
@@ -19,7 +19,7 @@ Whether you're building a small project or a large-scale application, **dotenv.n
1919- ** Simple and Pain-Free** 🎯: Easily load and read ` .env ` files with minimal setup.
2020- ** Flexible Configuration** 🔧: Customize how environment variables are loaded with a variety of options.
2121- ** Dependency Injection Support** 🧩: Works seamlessly with popular DI frameworks.
22- - ** Cross-Platform** 🌍: Fully compatible with .NET Core, .NET 5, and beyond.
22+ - ** Cross-Platform** 🌍: Fully compatible with .NET Core, .NET 5, .NET 6, .NET 9 and beyond.
2323- ** Open Source** 💡: Actively maintained and supported by the community.
2424
2525---
@@ -42,7 +42,7 @@ You can install **dotenv.net** via NuGet:
4242
4343- ** Manual Installation** (via ` .csproj ` ):
4444 ``` xml
45- <PackageReference Include =" dotenv.net" Version =" 4.0.0 " />
45+ <PackageReference Include =" dotenv.net" Version =" 4.x.x " />
4646 ```
4747
4848---
@@ -61,13 +61,43 @@ You can install **dotenv.net** via NuGet:
6161 DotEnv .Load ();
6262 ```
6363
64- This will automatically locate and load the ` .env ` file in the same directory as your application.
64+ This will automatically locate and load the ` .env ` file in the same directory as your application's executable.
65+
66+ ---
67+
68+ ### Fluent API 🎨
69+
70+ For a more expressive syntax, ** dotenv.net** provides a fluent API:
71+
72+ ``` csharp
73+ // Load environment variables with custom options
74+ DotEnv .Fluent ()
75+ .WithExceptions ()
76+ .WithEnvFiles (" ./path/to/env" )
77+ .WithTrimValues ()
78+ .WithEncoding (Encoding .ASCII )
79+ .WithOverwriteExistingVars ()
80+ .WithProbeForEnv (probeLevelsToSearch : 6 )
81+ .WithSupportExportSyntax ()
82+ .Load ();
83+
84+ // Read environment variables
85+ var envVars = DotEnv .Fluent ()
86+ .WithoutExceptions ()
87+ .WithEnvFiles () // Defaults to .env
88+ .WithoutTrimValues ()
89+ .WithEncoding (Encoding .UTF8 )
90+ .WithoutOverwriteExistingVars ()
91+ .WithoutProbeForEnv ()
92+ .WithoutSupportExportSyntax ()
93+ .Read ();
94+ ```
6595
6696---
6797
6898### Advanced Configuration ⚙️
6999
70- ** dotenv.net** offers a wide range of configuration options to tailor the loading process to your needs:
100+ ** dotenv.net** offers a wide range of configuration options to tailor the loading process to your needs using the ` DotEnvOptions ` class :
71101
72102- ** Specify Custom ` .env ` File Paths** :
73103 ``` csharp
@@ -112,36 +142,6 @@ Console.WriteLine(envVars["KEY"]); // Outputs the value associated with 'KEY'
112142
113143---
114144
115- ### Fluent API 🎨
116-
117- For a more expressive syntax, ** dotenv.net** provides a fluent API:
118-
119- ``` csharp
120- // Load environment variables with custom options
121- DotEnv .Fluent ()
122- .WithExceptions ()
123- .WithEnvFiles (" ./path/to/env" )
124- .WithTrimValues ()
125- .WithEncoding (Encoding .ASCII )
126- .WithOverwriteExistingVars ()
127- .WithProbeForEnv (probeLevelsToSearch : 6 )
128- .WithSupportExportSyntax ()
129- .Load ();
130-
131- // Read environment variables
132- var envVars = DotEnv .Fluent ()
133- .WithoutExceptions ()
134- .WithEnvFiles () // Defaults to .env
135- .WithoutTrimValues ()
136- .WithDefaultEncoding ()
137- .WithoutOverwriteExistingVars ()
138- .WithoutProbeForEnv ()
139- .WithoutSupportExportSyntax ()
140- .Read ();
141- ```
142-
143- ---
144-
145145### Environment Variable Helpers 🛠️
146146
147147The ` Utilities ` namespace provides additional methods for reading environment variables in a typed manner:
0 commit comments