{"id":28450433,"url":"https://github.com/netcorepal/netcorepal-cloud-template","last_synced_at":"2026-01-28T09:05:45.207Z","repository":{"id":133484913,"uuid":"487264263","full_name":"netcorepal/netcorepal-cloud-template","owner":"netcorepal","description":"基于netcorepal-cloud-framework的项目模板工具","archived":false,"fork":false,"pushed_at":"2026-01-08T02:43:48.000Z","size":31698,"stargazers_count":53,"open_issues_count":5,"forks_count":14,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-25T07:57:30.188Z","etag":null,"topics":["cleanddd","ddd","template-project"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netcorepal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-04-30T11:52:28.000Z","updated_at":"2026-01-08T02:42:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"c86bc62a-1ffc-490e-a7ad-c0e7e272d8e7","html_url":"https://github.com/netcorepal/netcorepal-cloud-template","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"purl":"pkg:github/netcorepal/netcorepal-cloud-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorepal%2Fnetcorepal-cloud-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorepal%2Fnetcorepal-cloud-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorepal%2Fnetcorepal-cloud-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorepal%2Fnetcorepal-cloud-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netcorepal","download_url":"https://codeload.github.com/netcorepal/netcorepal-cloud-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netcorepal%2Fnetcorepal-cloud-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28843142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T07:39:25.367Z","status":"ssl_error","status_checked_at":"2026-01-28T07:39:24.487Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cleanddd","ddd","template-project"],"created_at":"2025-06-06T15:07:28.445Z","updated_at":"2026-01-28T09:05:45.202Z","avatar_url":"https://github.com/netcorepal.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# 工程模板\n\n[![Release Build](https://img.shields.io/github/actions/workflow/status/netcorepal/netcorepal-cloud-template/release.yml?label=release%20build)](https://github.com/netcorepal/netcorepal-cloud-template/actions/workflows/release.yml)\n[![Preview Build](https://img.shields.io/github/actions/workflow/status/netcorepal/netcorepal-cloud-template/dotnet.yml?label=preview%20build)](https://github.com/netcorepal/netcorepal-cloud-template/actions/workflows/dotnet.yml)\n[![NuGet](https://img.shields.io/nuget/v/NetCorePal.Template.svg)](https://www.nuget.org/packages/NetCorePal.Template)\n[![NuGet Version](https://img.shields.io/nuget/vpre/NetCorePal.Template?label=nuget-pre)](https://www.nuget.org/packages/NetCorePal.Template)\n[![MyGet Version](https://img.shields.io/myget/netcorepal/vpre/NetCorePal.Template?label=myget-nightly)](https://www.myget.org/feed/netcorepal/package/nuget/NetCorePal.Template)\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/netcorepal/netcorepal-cloud-template/blob/main/LICENSE)\n\n## 简介\n\n本项目是一个基于dotnet new的模板项目，用于快速创建一个基于 [netcorepal-cloud-framework](https://github.com/netcorepal/netcorepal-cloud-framework) 的项目。\n\n项目支持`linux`、`windows`、`macOS`平台。\n\n## 前提条件\n\n1. 安装`.NET 10 SDK`（必需）。根据创建项目时选择的目标框架版本（`--Framework` 参数），您可能还需要安装对应的 SDK 版本：\n\n    - 使用 `--Framework net8.0` 时：需要安装 `.NET 8.0 SDK`\n    - 使用 `--Framework net9.0` 时：需要安装 `.NET 9.0 SDK`\n    - 使用 `--Framework net10.0` 时：仅需 `.NET 10 SDK`（默认）\n\n    SDK下载地址： \u003chttps://dot.net/download\u003e\n\n2. 拥有`Docker`环境，用于自动化单元测试和集成测试。\n\n    推荐工具：\n    \n    - **Docker Desktop**： \u003chttps://www.docker.com/products/docker-desktop/\u003e\n    - **Rancher Desktop**： \u003chttps://github.com/rancher-sandbox/rancher-desktop\u003e\n    - **OrbStack**： \u003chttps://orbstack.dev/download\u003e\n\n3. 如果使用 Aspire（使用 `--UseAspire` 参数创建项目时），需要配置 Aspire 环境。请按以下步骤操作：\n\n    **步骤 1：安装 Aspire SDK**\n\n    访问 [Aspire CLI 安装指南](https://aspire.dev/get-started/install-cli/) 按照官方文档安装 Aspire SDK。\n\n    **步骤 2：更新工作负载**\n\n    ```shell\n    dotnet workload update\n    ```\n\n    **步骤 3：信任 HTTPS 开发证书**\n\n    ```shell\n    dotnet dev-certs https --trust\n    ```\n\n## 如何使用\n\n安装模板\n\n``` shell\ndotnet new install NetCorePal.Template\n```\n\n安装Preview版本\n\n``` shell\ndotnet new install NetCorePal.Template::\u003cpackage-version\u003e\"\n\n# 例如\ndotnet new install NetCorePal.Template::3.1.0\n```\n\n安装Nightly版本\n\n``` shell\ndotnet new install NetCorePal.Template::\u003cpackage-version\u003e --add-source \"https://www.myget.org/F/netcorepal/api/v3/index.json\"\n```\n\n\n创建项目\n\n```shell\ndotnet new netcorepal-web -n My.Project.Name\n```\n\n### 命令参数说明\n\n模板支持多个参数来定制生成的项目，您可以根据需要选择不同的技术栈：\n\n#### 基本语法\n\n```shell\ndotnet new netcorepal-web -n \u003c项目名称\u003e [参数选项]\n```\n\n#### 获取帮助\n\n```shell\n# 查看所有可用的参数和选项\ndotnet new netcorepal-web --help\n\n# 查看所有已安装的模板\ndotnet new list\n```\n\n#### 可用参数\n\n| 参数 | 短参数 | 说明 | 可选值 | 默认值 |\n|------|--------|------|--------|--------|\n| `--Framework` | `-F` | 目标 .NET 框架版本 | `net8.0`, `net9.0`, `net10.0` | `net10.0` |\n| `--Database` | `-D` | 数据库提供程序 | `MySql`, `SqlServer`, `PostgreSQL`, `Sqlite`, `GaussDB`, `DMDB`, `MongoDB` | `MySql` |\n| `--MessageQueue` | `-M` | 消息队列提供程序 | `RabbitMQ`, `Kafka`, `AzureServiceBus`, `AmazonSQS`, `NATS`, `RedisStreams`, `Pulsar` | `RabbitMQ` |\n| `--UseAspire` | `-U` | 启用 Aspire Dashboard 支持 | `true`, `false` | `false` |\n| `--IncludeCopilotInstructions` | `-I` | 是否包含 Copilot 指令文件 | `true`, `false` | `true` |\n| `--UseAdmin` | | 是否包含 Admin 功能（用户、角色、部门管理、权限系统、前端） | `true`, `false` | `false` |\n\n#### 使用示例\n\n```shell\n# 使用默认配置（.NET 10.0 + MySQL + RabbitMQ）\ndotnet new netcorepal-web -n My.Project.Name\n\n# 使用 .NET 8.0 框架\ndotnet new netcorepal-web -n My.Project.Name --Framework net8.0\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -F net8.0\n\n# 使用 SQL Server 数据库\ndotnet new netcorepal-web -n My.Project.Name --Database SqlServer\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -D SqlServer\n\n# 使用 PostgreSQL 数据库\ndotnet new netcorepal-web -n My.Project.Name --Database PostgreSQL\n\n# 使用 SQLite 数据库（轻量级文件数据库，适合开发和测试）\ndotnet new netcorepal-web -n My.Project.Name --Database Sqlite\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -D Sqlite\n\n# 使用 MongoDB 数据库（NoSQL 文档数据库）\ndotnet new netcorepal-web -n My.Project.Name --Database MongoDB\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -D MongoDB\n\n# 使用 Kafka 消息队列\ndotnet new netcorepal-web -n My.Project.Name --MessageQueue Kafka\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -M Kafka\n\n# 组合使用多个参数（推荐使用短参数）\ndotnet new netcorepal-web -n My.Project.Name -F net8.0 -D PostgreSQL -M Kafka\n\n# 使用云服务（Azure Service Bus）\ndotnet new netcorepal-web -n My.Project.Name -M AzureServiceBus\n\n# 使用 Redis Streams 作为消息队列\ndotnet new netcorepal-web -n My.Project.Name -M RedisStreams\n\n# 启用 Aspire Dashboard 支持（用于可观测性和编排）\ndotnet new netcorepal-web -n My.Project.Name --UseAspire\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -U\n\n# 组合使用 Aspire 与其他选项\ndotnet new netcorepal-web -n My.Project.Name -F net9.0 -D PostgreSQL -U\n\n# 排除 Copilot 指令文件（不包含 .github 目录中的 copilot-instructions）\ndotnet new netcorepal-web -n My.Project.Name --IncludeCopilotInstructions false\n# 或使用短参数\ndotnet new netcorepal-web -n My.Project.Name -I false\n```\n\n\u003e **提示：** 创建项目后，请根据选择的数据库和消息队列配置，使用对应的基础设施初始化脚本来启动所需的服务。详细说明请参考生成项目中的 `scripts/README.md` 文件。\n\n### 关于 Admin 功能\n\n当启用 `--UseAdmin` 选项时，模板会包含以下功能：\n\n+ **用户管理**：用户的创建、更新、删除、查询等功能\n+ **角色管理**：角色的创建、更新、删除、权限分配等功能\n+ **部门管理**：部门的创建、更新、删除、树形结构管理等功能\n+ **权限系统**：基于角色的权限控制（RBAC），支持权限码定义和验证\n+ **JWT 认证**：完整的 JWT Token 认证和刷新 Token 机制\n+ **前端界面**：基于 Vue 3 + Vben Admin 的管理后台界面\n\n启用 Admin 功能后，系统会自动创建默认的管理员账户（用户名：`admin`，密码：`123456`）。\n\n### 关于 Aspire Dashboard\n\n当启用 `--UseAspire` 选项时，模板会生成以下额外的项目：\n\n+ **AppHost 项目**：用于应用程序的编排和启动，集成了 Aspire Dashboard\n+ **ServiceDefaults 项目**：包含共享的服务配置，如 OpenTelemetry、服务发现、健康检查等\n\n启用 Aspire Dashboard 后，可以通过运行 AppHost 项目来启动应用程序并访问 Dashboard：\n\n```shell\ncd src/My.Project.Name.AppHost\ndotnet run\n```\n\nAspire Dashboard 提供了以下功能：\n\n+ **分布式追踪**：可视化查看请求在不同服务间的流转\n+ **指标监控**：实时监控应用程序的性能指标\n+ **日志聚合**：集中查看所有服务的日志\n+ **服务健康检查**：监控各服务的健康状态\n+ **资源管理**：查看和管理应用程序使用的资源\n\n进入项目目录\n\n```shell\ncd My.Project.Name\n```\n\n构建项目\n\n```shell\ndotnet build\n```\n\n运行测试\n\n```shell\ndotnet test\n```\n\n## 本地开发\n\n如果您需要基于源码开发或调试本模板，可以按以下步骤操作：\n\n### 克隆仓库\n\n```bash\ngit clone https://github.com/netcorepal/netcorepal-cloud-template.git\ncd netcorepal-cloud-template\n```\n\n### 从本地源码安装模板\n\n#### 方式一：直接从源码目录安装（推荐）\n\n`dotnet new install` 支持直接从包含模板的源码目录安装，无需构建和打包：\n\n```bash\n# 建议先清理旧文件以避免冲突\ngit clean -fdX\n\n# 在项目根目录直接安装（推荐）\ndotnet new install . --force\n```\n\n`--force` 参数可以强制安装或更新模板，无需先卸载旧版本。这种方式最简单快捷，特别适合本地开发和调试。\n\n修改模板文件后，重新运行安装命令即可更新：\n\n```bash\n# 修改模板文件后，直接重新安装\ndotnet new install . --force\n```\n\n#### 方式二：从构建的包安装\n\n如果需要测试完整的打包流程，可以先构建再安装：\n\n```bash\n# 恢复依赖\ndotnet restore\n\n# 构建项目\ndotnet build\n\n# 打包模板\ndotnet pack\n\n# 从生成的 nupkg 文件安装\ndotnet new install ./bin/Debug/NetCorePal.Template.1.0.0.nupkg\n\n# 或者使用通配符安装\ndotnet new install ./bin/Debug/*.nupkg\n```\n\n### 测试本地模板\n\n安装后，您可以像使用正式版本一样创建项目来测试模板：\n\n```bash\n# 使用本地安装的模板创建项目\ndotnet new netcorepal-web -n TestProject\n\n# 进入测试项目目录\ncd TestProject\n\n# 构建和测试\ndotnet build\ndotnet test\n```\n\n### 查看已安装的模板\n\n```bash\n# 列出所有已安装的模板\ndotnet new list\n\n# 查看模板详细信息\ndotnet new netcorepal-web --help\n```\n\n## 其它命令\n\n更新模板\n\n``` shell\ndotnet new update\n```\n\nor\n\n```shell\ndotnet new install NetCorePal.Template::\u003cVERSION\u003e\n```\n\n卸载模板\n\n```shell\ndotnet new uninstall NetCorePal.Template\n```\n\n## IDE 代码片段配置\n\n本模板提供了丰富的代码片段，帮助您快速生成常用的代码结构。\n\n![代码片段演示](docs/snippets.gif)\n\n### Visual Studio 配置\n\n运行以下 PowerShell 命令自动安装代码片段：\n\n```powershell\ncd vs-snippets\n.\\Install-VSSnippets.ps1\n```\n\n或者手动安装：\n\n1. 打开 Visual Studio\n2. 转到 `工具` \u003e `代码片段管理器`\n3. 导入 `vs-snippets/NetCorePalTemplates.snippet` 文件\n\n### VS Code 配置\n\nVS Code 的代码片段已预配置在 `.vscode/csharp.code-snippets` 文件中，打开项目时自动生效。\n\n### JetBrains Rider 配置\n\nRider 用户可以直接使用 `ABC.Template.sln.DotSettings` 文件中的 Live Templates 配置。\n\n### 可用的代码片段\n\n#### NetCorePal (ncp) 快捷键\n\n| 快捷键 | 描述 | 生成内容 |\n|--------|------|----------|\n| `ncpcmd` | NetCorePal 命令 | ICommand 实现(含验证器和处理器) |\n| `ncpcmdres` | 命令(含返回值) | ICommand\u0026lt;Response\u0026gt; 实现 |\n| `ncpar` | 聚合根 | Entity\u0026lt;Id\u0026gt; 和 IAggregateRoot |\n| `ncprepo` | NetCorePal 仓储 | IRepository 接口和实现 |\n| `ncpie` | 集成事件 | IntegrationEvent 和处理器 |\n| `ncpdeh` | 域事件处理器 | IDomainEventHandler 实现 |\n| `ncpiec` | 集成事件转换器 | IIntegrationEventConverter |\n| `ncpde` | 域事件 | IDomainEvent 记录 |\n\n#### Endpoint (ep) 快捷键\n\n| 快捷键 | 描述 | 生成内容 |\n|--------|------|----------|\n| `epp` | FastEndpoint(NCP风格) | 完整的垂直切片实现 |\n| `epreq` | 仅请求端点 | Endpoint\u0026lt;Request\u0026gt; |\n| `epres` | 仅响应端点 | EndpointWithoutRequest\u0026lt;Response\u0026gt; |\n| `epdto` | 端点 DTOs | Request 和 Response 类 |\n| `epval` | 端点验证器 | Validator\u0026lt;Request\u0026gt; |\n| `epmap` | 端点映射器 | Mapper\u0026lt;Request, Response, Entity\u0026gt; |\n| `epfull` | 完整端点切片 | 带映射器的完整实现 |\n| `epsum` | 端点摘要 | Summary\u0026lt;Endpoint, Request\u0026gt; |\n| `epnoreq` | 无请求端点 | EndpointWithoutRequest |\n| `epreqres` | 请求响应端点 | Endpoint\u0026lt;Request, Response\u0026gt; |\n| `epdat` | 端点数据 | 静态数据类 |\n\n## 代码分析可视化\n\n框架提供了强大的代码流分析和可视化功能，帮助开发者直观地理解DDD架构中的组件关系和数据流向。\n\n### 🎯 核心特性\n\n+ **自动代码分析**：通过源生成器自动分析代码结构，识别控制器、命令、聚合根、事件等组件\n+ **多种图表类型**：支持架构流程图、命令链路图、事件流程图、类图等多种可视化图表\n+ **交互式HTML可视化**：生成完整的交互式HTML页面，内置导航和图表预览功能\n+ **一键在线编辑**：集成\"View in Mermaid Live\"按钮，支持一键跳转到在线编辑器\n\n### 🚀 快速开始\n\n安装命令行工具来生成独立的HTML文件：\n\n```bash\n# 安装全局工具\ndotnet tool install -g NetCorePal.Extensions.CodeAnalysis.Tools\n\n# 进入项目目录并生成可视化文件\ncd My.Project.Name/src/My.Project.Name.Web\nnetcorepal-codeanalysis generate --output architecture.html\n```\n\n### ✨ 主要功能\n\n+ **交互式HTML页面**：\n  + 左侧树形导航，支持不同图表类型切换\n  + 内置Mermaid.js实时渲染\n  + 响应式设计，适配不同设备\n  + 专业的现代化界面\n\n+ **一键在线编辑**：\n  + 每个图表右上角的\"View in Mermaid Live\"按钮\n  + 智能压缩算法优化URL长度\n  + 自动跳转到[Mermaid Live Editor](https://mermaid.live/)\n  + 支持在线编辑、导出图片、生成分享链接\n\n### 📖 详细文档\n\n完整的使用说明和示例请参考：\n\n+ [代码流分析文档](https://netcorepal.github.io/netcorepal-cloud-framework/zh/code-analysis/code-flow-analysis/)\n+ [代码分析工具文档](https://netcorepal.github.io/netcorepal-cloud-framework/zh/code-analysis/code-analysis-tools/)\n\n## 支持特性\n\n+ 文件存储\n  + [x] 本地文件\n  + [ ] 阿里云对象存储\n+ 配置管理\n  + [x] 文件配置（json、ini、yaml）\n  + [x] Kubernetes ConfigMap\n  + [ ] Nacos\n  + [ ] Apollo\n  + [ ] AgileConfig\n+ 数据库\n  + [x] SqlServer\n  + [x] MySql\n  + [x] PostgreSQL\n  + [x] Sqlite\n  + [x] GaussDB\n  + [x] DMDB\n  + [x] MongoDB\n+ 消息队列\n  + [x] RabbitMQ\n  + [x] Kafka\n  + [x] NATS\n  + [x] RedisStreams\n  + [x] AzureServiceBus\n  + [x] AmazonSQS\n  + [x] Pulsar\n+ 服务注册发现\n  + [x] Kubernetes\n  + [ ] Etcd\n  + [ ] Consul\n  + [ ] Zookeeper\n  + [ ] Eureka\n  + [ ] Nacos\n+ API工具链\n  + [x] Swagger\n+ 远程调用\n  + [ ] gRPC\n  + [x] HttpClient\n+ 实时通讯\n  + [x] SignalR\n  + [x] WebSocket\n+ 缓存中间件\n  + [x] Redis\n+ 熔断限流\n  + [x] Polly\n\n备注：未打勾表示该模板未集成该特性，但可手动添加。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcorepal%2Fnetcorepal-cloud-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetcorepal%2Fnetcorepal-cloud-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcorepal%2Fnetcorepal-cloud-template/lists"}