用途:为 .NET 项目生成应用现代最佳实践的完整解决方案脚手架,涵盖 src/、tests/ 与 .sln 结构,并配置中央包管理、分析器、.editorconfig、SourceLink 与确定性构建。
主要能力:创建目录布局与解决方案文件(.NET 9+ 可迁移为 .slnx);按应用类型选择模板(webapi、console、worker、classlib、blazor、maui、xunit 等);添加 global.json 固定 SDK 版本;通过 Directory.Build.props 共享 TargetFramework、Nullable、ImplicitUsings、TreatWarningsAsErrors、AnalysisLevel 等设置;通过 Directory.Build.targets 统一引入 SourceLink 等包;用 Directory.Packages.props 启用 CPM 与传递依赖固定;生成 .editorconfig、nuget.config(含 packageSourceMapping)、.gitignore;最后清理模板生成的重复属性与 Class1.cs。
使用方式:先运行 dotnet-version-detection 确定可用 SDK 版本。典型命令包括 mkdir -p MyApp/src MyApp/tests、dotnet new sln -n MyApp、dotnet sln MyApp.sln migrate、dotnet new webapi -n MyApp.Api -o src/MyApp.Api、dotnet sln add、dotnet add reference、dotnet new gitignore,以及验证用的 dotnet restore、dotnet build --no-restore、dotnet test --no-build。
适用场景:需要快速搭建结构统一、配置集中、可复现构建的 .NET 新项目或解决方案。
限制:不涉及解决方案布局理由与约定、分析器配置细节、CI 工作流生成,这些分别参见 dotnet-project-structure、dotnet-add-analyzers、dotnet-add-ci。具体模板与版本需按实际 SDK 调整。