使い方
- インストールコマンドをコピーし、自分の環境へ導入する前にソースを確認します。
- 必要なツール、認証情報、対応環境を原文で確認します。
- 入力と成果物を指定し、出力を資料と照合します。
npx skills add https://github.com/managedcode/dotnet-skills --skill microsoft-extensions開始前の確認
- 導入にはモデル契約、API枠、ファイルへのアクセス許可は含まれません。
- スター数や導入数は活動の指標であり、独立した品質・安全性試験ではありません。
見出し、例、コード、表、リンク、参照画像を含む原文を表示しています。
Microsoft.Extensions for .NET
Trigger On
- wiring dependency injection, configuration, logging, or options
- introducing Generic Host patterns into non-web .NET apps
- cleaning up service registration, typed HTTP clients, or shared infrastructure code
Workflow
- Prefer the Generic Host for apps that need configuration, DI, logging, hosted services, or coordinated startup.
- Keep service registration predictable: composition at the edge, concrete implementations hidden behind interfaces only where that abstraction buys flexibility.
- Use options binding for structured configuration and validate configuration at startup when bad settings would fail later at runtime.
- Prefer
IHttpClientFactoryand typed or named clients for outbound HTTP instead of ad-hoc singleton or per-callHttpClientusage. - Use logging categories and config-driven log levels rather than scattered ad-hoc logging behavior.
- For Kubernetes-hosted services, prefer the stable
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetespackage from the 10.7+ line when CPU/memory request and limit metrics should come from pod resource quotas. - Avoid building mini-frameworks over Microsoft.Extensions unless the repo genuinely needs reusable composition primitives.
Current Upstream Notes
dotnet/extensionsv10.9.0adds experimental AI routing and failover clients and includes HTTP diagnostics/source-logging fixes. Generic Host, dependency injection, configuration, logging, options, andIHttpClientFactorypatterns remain unchanged; route AI-specific architecture tomicrosoft-extensions-ai.- The MCP server project template moved out of
dotnet/extensionsand into the ASP.NET Core/.NET SDK distribution. Update scaffolding automation to use the SDK-provided template instead of pinning the removed extensions template package. - If repository automation creates AI templates from the prior
v10.8.4change, pass--provider azureopenai,--provider ollama, or--provider openaiexplicitly and validate the selected provider's secrets and local-development path. - Keep Microsoft.Extensions package versions aligned within the repo's selected servicing line, then rerun host startup and options-validation tests after upgrading.
Deliver
- clean host wiring and service registration
- configuration and logging that are observable and testable
- infrastructure code that fits naturally with the .NET stack
Validate
- service lifetimes are correct
- configuration is strongly typed where it matters
- host setup remains easy to debug and reason about
- Kubernetes resource monitoring uses the stable quota-provider APIs when pod request/limit dimensions matter
References
- patterns.md - DI patterns, Configuration patterns, Options pattern, Logging patterns, HttpClientFactory patterns, Hosted Service patterns
- anti-patterns.md - Common mistakes with DI, configuration, options, logging, HttpClient, and hosted services



