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
<PackageReference Include="Eigenverft.NetLib.Hosting.DirectoryLayout" Version="1.0.0.5" />
<PackageVersion Include="Eigenverft.NetLib.Hosting.DirectoryLayout" Version="1.0.0.5" />
<PackageReference Include="Eigenverft.NetLib.Hosting.DirectoryLayout" />
paket add Eigenverft.NetLib.Hosting.DirectoryLayout --version 1.0.0.5
#r "nuget: Eigenverft.NetLib.Hosting.DirectoryLayout, 1.0.0.5"
#:package Eigenverft.NetLib.Hosting.DirectoryLayout@1.0.0.5
#addin nuget:?package=Eigenverft.NetLib.Hosting.DirectoryLayout&version=1.0.0.5
#tool nuget:?package=Eigenverft.NetLib.Hosting.DirectoryLayout&version=1.0.0.5
Eigenverft.NetLib.Hosting.DirectoryLayout
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.0net10.0
A .NET 9 consumer can use the compatible net8.0 asset.
🔗 Project links
📄 License
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.Hosting (>= 10.0.0)
-
net8.0
- Microsoft.Extensions.Hosting (>= 8.0.1)
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.
Initial capability package extracted from Eigenverft.NetLib.Infrastructure.