1---
2name: dotnet-microsoft-extensions
3version: "1.0.0"
4category: "Core"
5description: "Use the Microsoft.Extensions stack correctly across Generic Host, dependency injection, configuration, logging, options, HttpClientFactory, and other shared infrastructure patterns."
6compatibility: "Relevant to console apps, workers, ASP.NET Core apps, functions, and reusable libraries."
7metadata:
8 source: https://skillmd.com/skills/aibot88/dotnet-microsoft-extensions
9---
10
11# Microsoft.Extensions for .NET
12
13## Trigger On
14
15- wiring dependency injection, configuration, logging, or options
16- introducing Generic Host patterns into non-web .NET apps
17- cleaning up service registration, typed HTTP clients, or shared infrastructure code
18
19## Workflow
20
211. Prefer the Generic Host for apps that need configuration, DI, logging, hosted services, or coordinated startup.
222. Keep service registration predictable: composition at the edge, concrete implementations hidden behind interfaces only where that abstraction buys flexibility.
233. Use options binding for structured configuration and validate configuration at startup when bad settings would fail later at runtime.
244. Prefer `IHttpClientFactory` and typed or named clients for outbound HTTP instead of ad-hoc singleton or per-call `HttpClient` usage.
255. Use logging categories and config-driven log levels rather than scattered ad-hoc logging behavior.
266. Avoid building mini-frameworks over Microsoft.Extensions unless the repo genuinely needs reusable composition primitives.
27
28## Deliver
29
30- clean host wiring and service registration
31- configuration and logging that are observable and testable
32- infrastructure code that fits naturally with the .NET stack
33
34## Validate
35
36- service lifetimes are correct
37- configuration is strongly typed where it matters
38- host setup remains easy to debug and reason about
39
40## References
41
42- [patterns.md](references/patterns.md) - DI patterns, Configuration patterns, Options pattern, Logging patterns, HttpClientFactory patterns, Hosted Service patterns
43- [anti-patterns.md](references/anti-patterns.md) - Common mistakes with DI, configuration, options, logging, HttpClient, and hosted services