Eigenverft.NetLib.Hosting.DirectoryLayout 1.0.0.5

dotnet add package Eigenverft.NetLib.Hosting.DirectoryLayout --version 1.0.0.5
                    
NuGet\Install-Package Eigenverft.NetLib.Hosting.DirectoryLayout -Version 1.0.0.5
                    
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="Eigenverft.NetLib.Hosting.DirectoryLayout" Version="1.0.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Eigenverft.NetLib.Hosting.DirectoryLayout" Version="1.0.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Eigenverft.NetLib.Hosting.DirectoryLayout" />
                    
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 Eigenverft.NetLib.Hosting.DirectoryLayout --version 1.0.0.5
                    
#r "nuget: Eigenverft.NetLib.Hosting.DirectoryLayout, 1.0.0.5"
                    
#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 Eigenverft.NetLib.Hosting.DirectoryLayout@1.0.0.5
                    
#: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=Eigenverft.NetLib.Hosting.DirectoryLayout&version=1.0.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Eigenverft.NetLib.Hosting.DirectoryLayout&version=1.0.0.5
                    
Install as a Cake Tool

Eigenverft.NetLib.Hosting.DirectoryLayout

NuGet Version NuGet Downloads Repository CI Targets License

Create predictable writable application folders below the executable directory and resolve the host environment before a Generic Host or ASP.NET Core builder exists.

✨ At a glance

Capability What it does Starting point
Standard folders Create the conventional logs, data, state, keys, certificates, and settings folders AddDefaultDirectoryLayout()
Custom folders Map application-defined semantic keys to direct child folders AddDirectoryLayout(...)
Host integration Register and retrieve the layout through IHostApplicationBuilder and DI IAppDirectoryLayout
Early environment Resolve the process host environment before builder creation StaticHostEnvironment

📦 Installation

dotnet add package Eigenverft.NetLib.Hosting.DirectoryLayout

🚀 Quick start

using System;
using Eigenverft.NetLib.Hosting.DirectoryLayout;
using Microsoft.Extensions.Hosting;

var builder = Host.CreateApplicationBuilder(args);
builder.AddDefaultDirectoryLayout();

IAppDirectoryLayout directories = builder.GetDirectoryLayout();
string settings = directories[DefaultDirectory.ApplicationSettings];
Console.WriteLine(settings);

using IHost host = builder.Build();
await host.RunAsync();

By default, the folders are direct children of AppContext.BaseDirectory. Registration creates each directory and probes it for write access so filesystem or permission errors surface during startup.

For ASP.NET Core, Eigenverft.WebLib.Hosting.DirectoryLayout builds on this package: it roots ContentRootPath at AppContext.BaseDirectory, sets WebRootPath to wwwroot, and exposes that folder through the semantic Web mapping. It delegates the shared application-directory creation and validation to this package; the NetLib package itself remains independent of ASP.NET Core.

📁 Standard and custom folders

The standard names are AppLogs, AppData, AppState, AppProtectionKeys, AppCerts, and AppSettings. Override only the names that need changing:

using System.Collections.Generic;
builder.AddDefaultDirectoryLayout(
    new Dictionary<DefaultDirectory, string>
    {
        [DefaultDirectory.ApplicationData] = "Data",
        [DefaultDirectory.ApplicationLogFiles] = "Logs",
    });

For app-specific keys, use a custom map:

using System.Collections.Generic;
builder.AddDirectoryLayout(
    new Dictionary<string, string>
    {
        ["Cache"] = "cache",
        ["Imports"] = "incoming",
    });

string imports = builder.GetDirectoryLayout()["Imports"];

Folder names must be single direct-child names. Rooted paths, separators, nested folders, and traversal patterns are rejected. The factory also supports an explicit root and optional writable checks when a Generic Host builder is not involved:

AppDirectoryLayout layout = AppDirectoryLayoutFactory.CreateDefault(
    rootPath: "path/to/root",
    verifyWritable: false);

🌱 Resolve the environment early

StaticHostEnvironment is available before creating a host builder, for bootstrap settings or other early startup decisions:

using Eigenverft.NetLib.Hosting.DirectoryLayout;
string environment = StaticHostEnvironment.EnvironmentName;
bool useDevelopmentBootstrap = StaticHostEnvironment.IsDevelopment;
bool useQaBootstrap = StaticHostEnvironment.IsEnvironment("QA");

Resolution precedence is process command-line arguments, then DOTNET_ENVIRONMENT, then ASPNETCORE_ENVIRONMENT, then Production. The value is captured once when the type is first initialized; arbitrary environment names are preserved and comparisons are case-insensitive.

🎯 Target frameworks

  • net8.0
  • net10.0

A .NET 9 consumer can use the compatible net8.0 asset.

📄 License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  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 (2)

Showing the top 2 NuGet packages that depend on Eigenverft.NetLib.Hosting.DirectoryLayout:

Package Downloads
Eigenverft.WebLib.Hosting.DirectoryLayout

Executable-rooted application directory layout and WebApplicationBuilder environment helpers for ASP.NET Core hosting.

Eigenverft.NetLib.Security.DataProtection

ASP.NET Core Data Protection adapters for the NetLib reversible-transform and configuration-value capabilities.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0.5 54 9/29/2026
1.0.0.4 76 9/28/2026
1.0.0.3 147 9/12/2026

Initial capability package extracted from Eigenverft.NetLib.Infrastructure.