一键导入
dotnet-shared-library-extraction
Extract shared code from a .NET Exe project into a class library for multi-project reuse
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extract shared code from a .NET Exe project into a class library for multi-project reuse
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
How to implement async credential prompting with proper error handling across multiple implementations (console, MCP elicitation, etc.)
How to safely use MCP Elicitation (ElicitAsync) in .NET MCP servers
基于 SOC 职业分类
| name | dotnet-shared-library-extraction |
| description | Extract shared code from a .NET Exe project into a class library for multi-project reuse |
| domain | architecture |
| confidence | high |
| source | earned: FinaryExport MCP architecture proposal |
When a .NET solution needs to share code between multiple executable projects (CLI, MCP server, web API), extract the shared code into a class library. This avoids referencing an Exe project (which drags in all its dependencies) and creates a clean dependency graph.
Keep the original RootNamespace on the new library. If the original project was FinaryExport with namespace FinaryExport, set <RootNamespace>FinaryExport</RootNamespace> on the new .Core library. This means zero using statement changes across the entire codebase — files physically move, namespaces don't.
Split ServiceCollectionExtensions. The original AddFinaryExport() becomes AddFinaryCore() in Core (registers only shared services). Each consuming project registers its own specializations (e.g., ICredentialPrompt implementation).
Interface stays in Core, implementations split by consumer. ICredentialPrompt in Core. ConsoleCredentialPrompt in CLI. EnvCredentialPrompt in MCP. Each host decides how credentials are collected.
Packages follow the code. If CurlImpersonate is used by Core code, the PackageReference goes on Core. Consuming projects get it transitively. Don't duplicate PackageReferences.
Validate with existing tests first. After extraction, the CLI project must build clean and all tests must pass before writing any new code. This is a refactoring gate.
Before: FinaryExport (Exe) → has everything
After: FinaryExport.Core (Library) → auth, api, models, infrastructure
FinaryExport (Exe) → CLI, export, console prompts → references Core
FinaryExport.Mcp (Exe) → MCP server, tools, env prompts → references Core
ConsoleCredentialPrompt has no business in a library that MCP references).