VOOZH about

URL: https://www.nuget.org/packages/Envy/

⇱ NuGet Gallery | Envy 1.2.0




Envy 1.2.0

dotnet add package Envy --version 1.2.0
 
 
NuGet\Install-Package Envy -Version 1.2.0
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Envy" Version="1.2.0" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Envy" Version="1.2.0" />
 
Directory.Packages.props
<PackageReference Include="Envy" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Envy --version 1.2.0
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Envy, 1.2.0"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Envy@1.2.0
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Envy&version=1.2.0
 
Install as a Cake Addin
#tool nuget:?package=Envy&version=1.2.0
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Envy

A utility library for loading environment variables into strongly-typed C# objects.

Inspired by the Rust crate of the same name.

Get it on NuGet.

Example

using Envy;

// create a special Env instance with the prefix "DB"
// now all variable accesses will be prefixed with "DB_" automatically
var env = Env.Vars.WithPrefix( "DB" );

// set some environment variables
// typically these would already be set in your environment
// but for the sake of this example, we'll set them here
// because of the prefix on env, the variables will be set as DB_HOST, DB_USER, and DB_PASS
env["HOST"] = "example.com";
env["USER"] = "admin";

// Env will automatically convert the case of the variable names to upper case
// so on our prefixed env, the variable name passed here is 'Pass' but it will internally resolve to 'DB_PASS'
env[nameof( DatabaseConnectionInfo.Pass )] = "hunter2";

// the underscore separator (or whatever separator you specify on Env.PrefixSeparator) is inserted automatically.
// DB is our prefix that goes before the variable name, separated by an Env.PrefixSeparator
// the prefix argument is optional and defaults to null for no prefix.
var connInfo = Env.Bind<DatabaseConnectionInfo>( "DB" );
// connInfo now looks like this:
// ╭──────────┬───────────────╮
// │ Name │ Value │
// ├──────────┼───────────────┤
// │ Host │ "example.com" │
// │ Port │ 27017 │
// │ User │ "admin" │
// │ Pass │ "hunter2" │
// │ Database │ null │
// ╰──────────┴───────────────╯

// connect to MongoDB

public sealed record DatabaseConnectionInfo
{
 public required string Host { get; init; }
 [Optional] public ushort Port { get; init; } = 27017;
 public string? User { get; init; }
 public string? Pass { get; init; }
 public string? Database { get; init; }
}
Product Versions Compatible and additional computed target framework versions.
.NET net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.2.0 7,105 3/19/2025
1.1.0 7,057 3/17/2025
1.0.0 7,048 3/16/2025