Giter VIP home page Giter VIP logo

dotenv.net's People

Contributors

bolorundurowb avatar caveman-dick avatar dtterastar avatar gounlaf avatar joliveros avatar jonlabelle avatar merqlove avatar mondonno avatar texyh avatar tracker1 avatar vijoplays avatar vizeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dotenv.net's Issues

Support for web.config

There is a lot of project still in .NET Framework and maybe it will be a good idea to add support for them or add a section with examples if this is now possible

Add DotEnv.AutoConfig()

It would be nice if it searched up from the current directory in order to find a .env up the chain without erroring.

using System;
using System.IO;
using System.Linq;
using DotEnv = dotenv.net.DotEnv;
...
namespace dotenv.net
{
    public class DotEnv
    {
        ...
        public static void AutoConfig() {
            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))
                {
                    Config(false, fi.FullName);
                    return; // found .env file
                }
            };
        }
    }
}

Quotation marks getting picked up by DotEnv

If I have a variable with a value that has a space in it, I have to use double quotation marks. However, when running this in ASP.NET Core 2.2, DotEnv includes the quotations marks in variable rather than understanding it's marking the start and end of the string. could it be possible to fix this bug? I require quotation marks for file paths in which folders have spaces, and I say it's a bug because this type of value is handled well in other dotenv package equivalents in other languages.

Make DotEnv Injectable

Awesome Project!

However, I think since it's supposed to work in .NET core, it should be injectable as a dependency in classes.

Especially since .NET core supports and encourages dependency injection.

Can retrieve a string

image
image

Exception non gérée : System.Exception: Value could not be retrieved. à dotenv.net.Utilities.EnvReader.GetStringValue(String key) à AccessBot.Program.Main(String[] args) dans D:\Developement\C#\Projects\AccessBot\AccessBot\Program.cs:ligne 17

i cant retrieve my value, any idea please ?

Environment and local config support

After working with another library that does this with node projects, it's enabled an easier path for configuring/using .env out of the box with projects.

In addition to default searching for .env file, search for the following file(s) in the following order...

  • .env.%DOTNET_ENV%.local
  • .env.%DOTNET_ENV%
  • .env.local
  • .env

Where %DOTNET_ENV% uses the environment variable if already set.


Related to #11 and #22

support export VAR=value

it would be nice if in addition to

KC_ADDR=...

that this also was supported

export KC_ADDR=...

Starting directory different between envFilePaths and probeForEnv.

There's a slightly confusing difference between using envFilePaths and probeForEnv.

When you specify envFilePaths, the paths are relative to the current directory (i.e. Directory.GetCurrentDirectory();). For example if I specify a relative path ..\.env it's one directory up from the current directory.

When you specify probeForEnv, it begins searching from AppContext.BaseDirectory. This isn't usually the same as the current directory. For example:

AppContext.BaseDirectory         => C:\MyApp\MyApp.Web\bin\Debug\net6.0\
Directory.GetCurrentDirectory()  => C:\MyApp\MyApp.Web\

So if I had a file C:\MyApp\.env using probeForEnv wouldn't find it (with the default 4 levels to search), but using the explicit path ..\.env would find it. I found this confusing until I looked at the source code.

Add Support for autofac.

Right now, i dont think there is an easy way of configuring this with autofac. please can that feature be added. I can also raise a PR for that

Getting error "The file path cannot be null, empty or whitespace. (Parameter 'envFilePath')"

I keep getting the error The file path cannot be null, empty or whitespace. (Parameter 'envFilePath').

I'm using it from F# like this:

[<EntryPoint>]
let main _ =
    let opts =
        new DotEnvOptions(probeForEnv = true, probeLevelsToSearch = 2, ignoreExceptions = false)

    DotEnv.Load(opts)

As far as I can tell from the docs envFilePaths isn't a required parameter and either way it's envFilePath in the singular that's in the error message so it looks to me like a bug.

Bug with "=" in the value side

If I put any "=" in the value side, like:

variable=123456789=

With any subsequente "=", the value returned will be: 123456789 because of dotEnvRow.Split and the fact that you just use the first and second keyValue's.

I think you could find the first "=" and manually separate the line in a key/value pair, value being the rest of the line.

Autofac Dependency should be in another package

Hi,

You recently decided to provide easy DI for your package, the thing is, you provided your package with direct dependency of AutoFac on version 2.0+

Do you think you can split the AutoFac DI extensions to another package ? like dotenv.net.AutoFac

Thanks for your library.

support parsing .env and returning a Dictionary<string,string> instead of modifying environment

in Microsoft.Extensions.Configuration, ConfigurationBuilder has the ability to load configuration from a dictionary.

Because of that, it would be nice to support using dotenv.net to parse the .env file and return it as a dictionary then allow the caller to use that dictionary.

Currently because it doesn't support returning a dictionary instead of modifying the environment, a .net core test project wanting to use it must switch their <Project Sdk= value from Microsoft.NET.Sdk to Microsoft.NET.Sdk.Web so they can use AddEnvironmentVariables

Ideally this would also support the "look up the directory chain for the .env file" like AutoConfig, but if not by default then maybe by separate Parse and AutoParse (?) methods. If that's not allowed, maybe refactor out the "find nearest .env up the directory chain" from AutoConfig into a FindNearestDotEnv (or whatever name) and then callers could use it and then pass to Parse.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.