本项目是一个基于dotnet new的模板项目,用于快速创建一个基于 netcorepal-cloud-framework 的项目。
项目支持linux
、windows
、macOS
平台。
-
安装
.NET 9.0 SDK
或更高版本。SDK下载地址: https://dot.net/download
-
拥有
Docker
环境,用于自动化单元测试和集成测试。Docker Desktop
下载地址: https://www.docker.com/products/docker-desktop/
安装模板
dotnet new install NetCorePal.Template
安装Preview版本
dotnet new install NetCorePal.Template::<package-version> --add-source "https://www.myget.org/F/netcorepal/api/v3/index.json"
创建项目
dotnet new netcorepal-web -n My.Project.Name
进入项目目录
cd My.Project.Name
构建项目
dotnet build
运行测试
dotnet test
更新模板
dotnet new update
or
dotnet new install NetCorePal.Template::<VERSION>
卸载模板
dotnet new uninstall NetCorePal.Template
本模板提供了丰富的代码片段,帮助您快速生成常用的代码结构。
运行以下 PowerShell 命令自动安装代码片段:
cd vs-snippets
.\Install-VSSnippets.ps1
或者手动安装:
- 打开 Visual Studio
- 转到
工具
>代码片段管理器
- 导入
vs-snippets/NetCorePalTemplates.snippet
文件
VS Code 的代码片段已预配置在 .vscode/csharp.code-snippets
文件中,打开项目时自动生效。
Rider 用户可以直接使用 ABC.Template.sln.DotSettings
文件中的 Live Templates 配置。
快捷键 | 描述 | 生成内容 |
---|---|---|
ncpcmd |
NetCorePal 命令 | ICommand 实现(含验证器和处理器) |
ncpcmdres |
命令(含返回值) | ICommand<Response> 实现 |
ncpar |
聚合根 | Entity<Id> 和 IAggregateRoot |
ncprepo |
NetCorePal 仓储 | IRepository 接口和实现 |
ncpie |
集成事件 | IntegrationEvent 和处理器 |
ncpdeh |
域事件处理器 | IDomainEventHandler 实现 |
ncpiec |
集成事件转换器 | IIntegrationEventConverter |
ncpde |
域事件 | IDomainEvent 记录 |
快捷键 | 描述 | 生成内容 |
---|---|---|
epp |
FastEndpoint(NCP风格) | 完整的垂直切片实现 |
epreq |
仅请求端点 | Endpoint<Request> |
epres |
仅响应端点 | EndpointWithoutRequest<Response> |
epdto |
端点 DTOs | Request 和 Response 类 |
epval |
端点验证器 | Validator<Request> |
epmap |
端点映射器 | Mapper<Request, Response, Entity> |
epfull |
完整端点切片 | 带映射器的完整实现 |
epsum |
端点摘要 | Summary<Endpoint, Request> |
epnoreq |
无请求端点 | EndpointWithoutRequest |
epreqres |
请求响应端点 | Endpoint<Request, Response> |
epdat |
端点数据 | 静态数据类 |
- 文件存储
- 本地文件
- 阿里云对象存储
- 配置管理
- 文件配置(json、ini、yaml)
- Kubernetes ConfigMap
- Nacos
- Apollo
- AgileConfig
- 数据库
- InMemory
- SqlServer
- MySql
- PostgreSql
- Sqlite
- 消息队列
- RabbitMQ
- Kafka
- RedisStreams
- AzureServiceBus
- AmazonSQS
- Pulsar
- 服务注册发现
- Kubernetes
- Etcd
- Consul
- Zookeeper
- Eureka
- Nacos
- API工具链
- Swagger
- 远程调用
- gRPC
- HttpClient
- 实时通讯
- SignalR
- WebSocket
- 缓存中间件
- Redis
- 熔断限流
- Polly