CleanArchitecture README

The project's README from github.com/ardalis/CleanArchitecture. As one markdown file: README.md.

.NET Core publish Ardalis.CleanArchitecture Template to nuget Ardalis.CleanArchitecture.Template on NuGet

Follow @ardalis   Follow @nimblepros

Alt

Clean Architecture

A starting point for Clean Architecture with ASP.NET Core. Clean Architecture is just the latest in a series of names for the same loosely-coupled, dependency-inverted architecture. You will also find it named hexagonal, ports-and-adapters, or onion architecture.

Learn more about Clean Architecture and this template in NimblePros' Introducing Clean Architecture course. Use code ARDALIS to save 20%.

This architecture is used in the DDD Fundamentals course by Steve Smith and Julie Lerman.

:school: Contact Steve's company, NimblePros, for Clean Architecture or DDD training and/or implementation assistance for your team.

Take the Course!

Learn about how to implement Clean Architecture from NimblePros trainers Sarah "sadukie" Dutkiewicz and Steve "ardalis" Smith.

Table Of Contents

Give a Star! :star:

If you like or are using this project to learn or start your solution, please give it a star. Thanks!

Or if you're feeling really generous, we now support GitHub sponsorships - see the button above.

Sponsors

I'm please to announce that Amazon AWS's FOSS fund has chosen to award a 12-month sponsorship to this project. Thank you, and thanks to all of my other past and current sponsors!

Troubleshooting Chrome Errors

By default the site uses HTTPS and expects you to have a self-signed developer certificate for localhost use. If you get an error with Chrome see this answer for mitigation instructions.

Versions

The main branch is now using .NET 9. This corresponds with NuGet package version 10.x. Previous versions are available - see our Releases.

Learn More

Documentation

The official documentation for this template, including Getting Started steps, Migration Guides, and Architectural Decisions, can be found at Ardalis Clean Architecture Docs.

If you are upgrading from an older version, please be sure to review our Migration Guides on the new documentation site!

CleanArchitecture (ardalis/CleanArchitecture)

Searching Database…

这是什么?一个 ASP.NET Core 解决方案模板,为你提供一个经过验证的整洁架构(Clean Architecture)起点——一种松耦合、依赖反转的项目布局,也被称为六边形架构、端口与适配器架构或洋葱架构。
它是能加到我项目里的框架或库吗?都不是——它是一个 dotnet CLI 项目模板。安装之后,它会生成一套完整的 ASP.NET Core 解决方案(包含 Core、Use Cases、Infrastructure 和 Web 项目,以及测试项目),你可以在里面构建自己的应用。
怎么用它开始一个项目?先用 dotnet CLI 安装模板(dotnet new install Ardalis.CleanArchitecture.Template),然后用 dotnet new clean-arch 生成完整版解决方案,或者用 dotnet new min-clean 生成精简版。其余步骤可以参考官方文档的 Getting Started 部分。
我需要先装特定版本的 .NET 吗?是的——需要 .NET SDK。README 里说明 main 分支现在使用 .NET 9,对应 NuGet 包版本 10.x,早期环境可以使用旧版本的模板。
安装配置上有什么要注意的坑吗?生成的网站通过 HTTPS 运行,需要 localhost 使用自签名的开发者证书,这在 Chrome 中可能报错——README 里附有解决方法的链接。
它会不会把我绑死在 Windows 和 Visual Studio 上?不会——一切操作都通过跨平台的 dotnet CLI 完成,而且这个仓库的 CI 会运行跨平台的构建和测试流程,所以 Linux 和 macOS 也完全没问题。
完整版模板和精简版模板有什么区别?clean-arch 是包含所有项目和模式的完整解决方案,而 min-clean 是精简变体,需要删掉的样板代码更少。README 中的 Template Comparison 部分(Which Template Should I Use?)可以帮你做选择。
我只能用 Minimal API 吗,还是也可以用 Controllers 和 Razor Pages?这个模板偏向通过 Ardalis.ApiEndpoints 包来使用 API 端点,但如果你更喜欢 Controllers 或 Razor Pages,README 里也写了如何添加它们。
它是不是偏向领域驱动设计(DDD)?确实有这个倾向:领域事件(Domain Events)是文档中列出的模式之一,同样的架构也是 Steve Smith 和 Julie Lerman 的 NimblePros DDD Fundamentals 课程的基础。不过整洁架构本身是一个更宽泛的松耦合理念,并不专指 DDD。
我用的是较旧的模板版本——升级麻烦吗?不算麻烦:官方文档站提供了在不同版本之间迁移的 Migration Guides,README 也建议升级前先看一看。
Creator
ardalis
Size
3.6 MB
Stars
18.5K
Age
10y
Commits · 90 Days