Roadmap › .NET Project Architectures & Folder Structures — Layered, Clean, Onion, Vertical Slice › Module: Solution Basics
Lessons in this course (8)
1. Solutions, projects, references and naming conventions
Basic★ Must knowLesson 1 of 8
bash
dotnet new sln -n Shop
dotnet new classlib -n Shop.Domain -o src/Shop.Domain
dotnet new classlib -n Shop.Application -o src/Shop.Application
dotnet new classlib -n Shop.Infrastructure -o src/Shop.Infrastructure
dotnet new webapi -n Shop.Api -o src/Shop.Api
dotnet new xunit -n Shop.UnitTests -o tests/Shop.UnitTests
dotnet sln add src/**/*.csproj tests/**/*.csproj
dotnet add src/Shop.Application reference src/Shop.Domain
dotnet add src/Shop.Infrastructure reference src/Shop.Application
dotnet add src/Shop.Api reference src/Shop.Application src/Shop.InfrastructureRepository layout (common convention):
text
Shop/
├── src/ production projects
├── tests/ test projects (mirror src names + .UnitTests / .IntegrationTests)
├── docs/ architecture decision records (ADRs), diagrams
├── build/ or eng/ build scripts, pipeline templates
├── deploy/ Dockerfiles, Bicep/Terraform, Helm charts
├── .github/ or .azuredevops/ CI/CD pipelines
├── Directory.Build.props shared MSBuild settings for all projects
├── Directory.Packages.props central NuGet package versions
├── global.json pinned .NET SDK version
├── .editorconfig code style rules
└── Shop.sln (or Shop.slnx)Naming: Company.Product.Layer (Divakar.Shop.Domain), namespaces match folders, one public type per file, plural folder names for collections of things (Controllers, Entities), test classes named <ClassUnderTest>Tests.
xml
<!-- Directory.Build.props: applies to every project below this folder -->
<Project>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
<!-- Directory.Packages.props: <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> + <PackageVersion Include="Dapper" Version="2.1.66" /> -->