Skip to content

Commit 1a9e933

Browse files
committed
updated readmes
1 parent 451fbd1 commit 1a9e933

File tree

29 files changed

+174
-732
lines changed

29 files changed

+174
-732
lines changed

01-basic-console/README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
# 02 - Basic Console
1+
## Overview
22

3-
Minimal .NET console template baseline. Used as a control sample before adding configuration providers.
3+
- Baseline .NET console sample with top-level statements.
4+
- Use as the control before layering configuration providers.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 02-basic-console
9+
dotnet run --project 01-basic-console/BasicConsole.csproj
910
```
10-
11-
## Key Points
12-
13-
- Single `Program.cs` using top-level statements.
14-
- Prints "Hello, World!".
15-
- No configuration providers yet (contrast with later samples).

02-generic-host/README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# 01 - Generic Host
1+
## Overview
22

3-
Introduces generic host template using `Host.CreateApplicationBuilder`.
3+
- Shows Host.CreateApplicationBuilder scaffolding for configuration, logging, and DI.
4+
- Demonstrates long-running host lifetime versus a simple console exit.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 01-generic-host
9+
dotnet run --project 02-generic-host/GenericHost.csproj
910
```
10-
11-
## Key Points
12-
13-
- Foundation for adding services, logging, configuration in a structured way.
14-
- Execution continues after initial code until host shutdown.

03-json-config/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
# 03 - JSON Configuration
1+
## Overview
22

3-
Introduces the JSON configuration provider via `AddJsonFile("config.json")`.
3+
- Loads config.json via AddJsonFile.
4+
- Reads values with the IConfiguration indexer.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 03-json-config
9+
dotnet run --project 03-json-config/JsonConfig.csproj
910
```
10-
11-
## Key Points
12-
13-
- Builds an `IConfigurationRoot` with a single JSON file.
14-
- Accesses values using indexer: `configuration["greeting"]`.
15-
- Establishes baseline for precedence demos (env vars, command line) in later samples.
16-
17-
## Try
18-
19-
Edit `config.json` and re-run to see value changes (no reload-on-change here).

04-environment-variables/README.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
1-
# 04 - Environment Variables
1+
## Overview
22

3-
Adds `AddEnvironmentVariables()` showing how environment variables override JSON values.
3+
- Adds environment variables provider on top of JSON.
4+
- Illustrates overriding keys such as environment or greeting.
45

56
## Run
67

78
```powershell
8-
$env:environment = "qa"
9-
dotnet run --project 04-environment-variables
9+
dotnet run --project 04-environment-variables/EnvironmentVariables.csproj
1010
```
1111

12-
### Bash
12+
## Notes
1313

14-
```bash
15-
environment=qa dotnet run --project 04-environment-variables
16-
```
17-
18-
## Key Points
19-
20-
- Provider order: JSON then Environment -> env vars win when keys collide.
21-
- Cross-platform examples (PowerShell / bash) moved from code comments to README.
22-
23-
## Try
24-
25-
Set `greeting` or `environment` via environment variable and verify override.
14+
- Set environment variables in your shell before running (PowerShell: $env:environment='qa').

05-command-line-args/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
1-
# 05 - Command Line Arguments
1+
## Overview
22

3-
Adds `AddCommandLine(args)` to show highest-precedence overrides.
3+
- Adds command-line configuration for highest-precedence overrides.
4+
- Mixes environment variables and switches to highlight precedence order.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 05-command-line-args -- --environment=prod --greeting=Hey
9+
dotnet run --project 05-command-line-args/CommandLineArgs.csproj -- --environment=prod --greeting=Hey
910
```
1011

11-
## Precedence (Highest → Lowest)
12-
13-
1. Command line
14-
2. Environment variables
15-
3. JSON file
16-
17-
## Try
18-
19-
Combine env vars + command line to observe override order.
20-
2112
### Examples
2213

2314
```bash
@@ -26,3 +17,7 @@ environment=qa dotnet run --project 05-command-line-args
2617
environment=qa dotnet run --project 05-command-line-args -- --environment=prod
2718
greeting=hey dotnet run --project 05-command-line-args -- --environment=prod
2819
```
20+
21+
## Notes
22+
23+
- Remember the -- separator so dotnet passes switches through to the app.

06-in-memory-config/README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
# 06 - In-Memory Configuration
1+
## Overview
22

3-
Uses `AddInMemoryCollection` to seed configuration dynamically at runtime.
3+
- Seeds configuration with AddInMemoryCollection.
4+
- Useful for tests or runtime-only defaults.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 06-in-memory-config
9+
dotnet run --project 06-in-memory-config/InMemoryConfig.csproj
910
```
10-
11-
## Key Points
12-
13-
- Great for tests or programmatic seeding.
14-
- Shows accessing a key not present (`SomeKey`) returning null.
15-
- Prepares for binding + sections in later demos.

07-user-secrets/README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
# 07 - User Secrets
1+
## Overview
22

3-
Demonstrates `AddUserSecrets<Program>()` for local secret storage (development only).
4-
5-
## Setup
6-
7-
```powershell
8-
dotnet user-secrets init --project 07-user-secrets
9-
dotnet user-secrets set "greeting" "SecretHello" --project 07-user-secrets
10-
```
3+
- Loads secrets from the user secrets store during Development.
4+
- Keeps API keys out of source control.
115

126
## Run
137

148
```powershell
15-
dotnet run --project 07-user-secrets
9+
dotnet run --project 07-user-secrets/UserSecrets.csproj
1610
```
1711

18-
## Key Points
12+
## Notes
1913

20-
- User secrets override JSON but are not checked into source.
21-
- Suitable for API keys during local dev; not for production.
14+
- Initialize secrets via 'dotnet user-secrets init --project 07-user-secrets' and set the expected keys before running.
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
# 09 - Configuration Sections
1+
## Overview
22

3-
Demonstrates hierarchical keys (e.g. `greeting:message`) and retrieving nested values.
3+
- Explores hierarchical sections such as Greeting:Message.
4+
- Shows how nested keys flow from JSON, environment variables, and command-line arguments.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 09-configuration-sections -- --greeting:color=blue
9+
dotnet run --project 08-configuration-sections -- --greeting:color=blue
910
```
1011

1112
### Additional Examples
1213

1314
```bash
14-
dotnet run --project 09-configuration-sections -- --greeting:color=green
15+
dotnet run --project 08-configuration-sections -- --greeting:color=green
16+
dotnet run --project 08-configuration-sections/ConfigurationSections.csproj
1517
```
16-
17-
## Key Points
18-
19-
- Shows colon-delimited keys for hierarchy.
20-
- Mixes JSON + environment + (optional) user secrets + command line.
21-
- Basis for section binding in later samples.

09-command-line-mappings/README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
# 08 - Command Line Mappings
1+
## Overview
22

3-
Adds a custom switch mapping dictionary to map friendly switches to config keys.
3+
- Maps friendly switches to configuration keys with AddCommandLine(args, mappings).
4+
- Still supports raw colon-delimited arguments when needed.
45

56
## Run
67

78
```powershell
8-
dotnet run --project 08-command-line-mappings -- --color=green --greeting="Hi"
9+
dotnet run --project 09-command-line-mappings/CommandLineMappings.csproj -- --color=green
910
```
1011

1112
### Additional Examples
1213

1314
```bash
14-
dotnet run --project 08-command-line-mappings -- --greeting:color=blue
15-
dotnet run --project 08-command-line-mappings -- --color=blue
15+
dotnet run --project 09-command-line-mappings -- --greeting:color=blue
16+
dotnet run --project 09-command-line-mappings -- --color=blue
1617
```
17-
18-
## Key Points
19-
20-
- Demonstrates `AddCommandLine(args, mappings)`.
21-
- Enables shorter / domain-friendly switches.
22-
- Both mapped and raw hierarchical syntax work.

10-key-per-file/README.md

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,10 @@
1-
# 14 - Key Per File Provider
1+
## Overview
22

3-
Reads individual config values from files in a directory using `AddKeyPerFile`.
4-
5-
## Directory
6-
7-
`keyPerFile/` contains one file per key. File name = key; file content = value.
3+
- Uses AddKeyPerFile to read secrets from the keyPerFile/ directory.
4+
- Great for Docker or Kubernetes mounted secrets.
85

96
## Run
107

118
```powershell
12-
dotnet run --project 14-key-per-file
13-
```
14-
15-
### Environment Override Examples (PowerShell)
16-
17-
```powershell
18-
$Env:ENVIRONMENT="qa"; dotnet run --project 14-key-per-file
19-
$Env:ENVIRONMENT="production"; dotnet run --project 14-key-per-file
20-
$Env:ENVIRONMENT=$NULL; dotnet run --project 14-key-per-file
9+
dotnet run --project 10-key-per-file/KeyPerFile.csproj
2110
```
22-
23-
## Key Points
24-
25-
- Useful for Kubernetes secrets (mounted files).
26-
- `optional: true` allows directory absence without failure.
27-
- `GetDebugView()` demonstrates provider/value origins.

0 commit comments

Comments
 (0)