ASP.NET Core Web API project structure

ASP.NET Core Web API project structure

Explorer

  • .confignew
  • dotnet-tools.jsonnew
  • .git…
  • .vscodenew
  • extensions.jsonnew
  • settings.jsonnew
  • src
  • testsnew
  • .editorconfig
  • .env.examplenew
  • .gitattributesnew
  • .gitignore
  • AGENTS.mdnew
  • CLAUDE.mdnew
  • compose.yamlnew
  • Directory.Build.propsnew
  • Directory.Packages.propsnew
  • global.jsonnew
  • README.md
  • Shop.slnx
  1. # Create the solution (a .slnx file by default on the .NET 10 SDK)

    mkdir Shop && cd Shop && dotnet new sln -n Shop
  2. # Create the API project (add --use-controllers for controllers instead of minimal APIs)

    dotnet new webapi -n Shop.Api -o src/Shop.Api
  3. # Repository files from the official item templates

    dotnet new gitignore && dotnet new editorconfig
  4. # Growing: class libraries for the clean architecture split

    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
  5. # Growing: unit and integration test projects

    dotnet new xunit -n Shop.UnitTests -o tests/Shop.UnitTests && dotnet new xunit -n Shop.IntegrationTests -o tests/Shop.IntegrationTests
  6. # Growing: shared build settings, central package versions and a pinned SDK

    dotnet new buildprops && dotnet new packagesprops && dotnet new globaljson
  7. # Growing: the EF Core CLI as a local tool

    dotnet new tool-manifest && dotnet tool install dotnet-ef
  8. # Add every project to the solution

    dotnet sln add src/*/*.csproj tests/*/*.csproj
  9. # Expert: Aspire AppHost and ServiceDefaults projects

    dotnet new aspire-apphost -n Shop.AppHost -o src/Shop.AppHost && dotnet new aspire-servicedefaults -n Shop.ServiceDefaults -o src/Shop.ServiceDefaults