Dotnet Env Versions Save

A .NET library to load environment variables from .env files

v3.0.0

4 months ago
  • Parse unquoted values slightly differently to properly parse comments, rejecting quote chars, allow leading and trailing whitespace in interpolated values, do not allow values to start with # anymore, give better errors on invalid quoted values, etc
  • Rename ToDictionary to ToDotEnvDictionary for clarity, and add options for behavior
  • Get rid of the warnings about vulnerabilities in System.Net.Http 4.3.0 (which was unused)

v2.5.0

1 year ago

Revert the change from Directory.GetCurrentDirectory() to AppContext,BaseDirectory as it broke existing applications

v2.4.0

1 year ago

DO NOT USE -- the change in directory did in fact break behavior for at least one existing application. Move to 2.5.0

  • Replace the default path from Directory.GetCurrentDirectory() with just AppContext.BaseDirectory -- which should do the same thing, except make things better for some cases, per #69
  • Add the newly contributed ConfigurationBuilder integration

v2.3.0

2 years ago

Adds a new EnvReader helper class #65

v2.2.0

2 years ago

Allow dash and period in env var identifiers

v2.1.1

3 years ago

Properly handle dollar signs in values

v2.1.0

3 years ago

https://www.nuget.org/packages/DotNetEnv/2.1.0

Technically this includes 2 breaking changes, but it is highly unlikely anyone is using them, and the changes are clear improvements.

  • Adds Env.LoadMulti for loading multiple .env files on top of each other
  • Removes Env.Load for list of lines -- was only used for tests here and highly discouraged for deployed use as it effectively defines hardcoded env vars in code. If you need to reproduce this functionality, use LoadContents with "\n"s between lines in a single string.
  • Unquoted values can now include inline whitespace -- but still allow for comments at the end, even while allowing inline hashes in a word (to support k8s configmap from env)

Again, note that this changes the behavior of unquoted values in a noticeable way -- but before this would have been a parse error, so this simply makes it more flexible than it used to be.

v2.0.0

3 years ago

This version has many breaking changes! Most of them will probably not bite you, but you should test.

  • Completely replace previous parsing logic with all new using Monadic Parser Combinators via Sprache which enables many of the rest of these changes, and should be much more robust -- and more consistent with other dotenv libraries (i.e. reuse dotenv files, hopefully, or more easily, at least -- there is a widespread lack of consistency here).
  • Changes the rules for quoted strings: single and double quotes behave differently from each other and before, notably allowing multiline strings -- but removing interpolation from single quoted strings
  • Changes the rules for unquoted strings: trim whitespace is effectively always on and no whitespace is allowed inside such unquoted strings (although you can interpolated variables here, which themselves could have whitespace in their values)
  • Allow for hash chars inside quoted values (and unquoted, as it happens)
  • Allow for multiline quoted values (e.g. MULTILINE="line1 ... line2 ... line3 ... etc" across multiple lines in a single .env file within a single pair of quotes)
  • Parse variables in the ${ENVVAR} form in addition to $ENVVAR
  • Allow for lines to start with export (and other such env var setting commands) to allow for .env files to be directly source-d in a terminal
  • Add a new return value from Load that has all the keys and values set in an IEnumerable<KeyValuePair<string, string>> -- including duplicate keys, so an extension ToDictionary() method is also included to convert that enumerable into a unique key dictionary for configuration loading
  • Add fluent methods to turn off options for Load -- and remove all old options related to parsing, leaving only clobberExistingVars, while adding setEnvVars and onlyExactPath for disabling side effects (setting env vars) and traversing up the path to find an .env file, respectively

v1.4.0

4 years ago
  • Remove requireEnvFile arg from LoadOptions and make env file permanently not required
  • Remove obsolete Load overloads with parameterized arguments (instead of LoadOptions object)

v1.3.1

4 years ago

Updated the way that the license is referenced in the csproj so as to appease new nuget rules for such things...