100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
.NET

Project and Solution Structure

How .csproj project files and .sln solution files organize .NET code, dependencies, and multi-project applications.

FoundationsBeginner8 min readJul 10, 2026
Analogies

Project and Solution Structure

A .NET project is defined by a single .csproj (or .fsproj/.vbproj) XML file that declares the target framework, package references, and build settings; a solution is a .sln file that groups one or more related projects so they can be opened, built, and versioned together in an IDE like Visual Studio or Rider. Modern .csproj files use an SDK-style format that is short and implicit — files under the project folder are automatically included by glob pattern rather than listed individually.

🏏

Cricket analogy: Like a single player's contract (.csproj) specifying their role, salary, and team versus the full squad list (.sln) that groups every player's contract for the season, a project file governs one component while a solution groups several.

Anatomy of a .csproj File

An SDK-style .csproj begins with <Project Sdk="Microsoft.NET.Sdk"> (or Microsoft.NET.Sdk.Web for ASP.NET Core), and inside a <PropertyGroup> it declares settings like <TargetFramework>net8.0</TargetFramework>, <Nullable>enable</Nullable>, and <ImplicitUsings>enable</ImplicitUsings>. <PackageReference> elements inside an <ItemGroup> declare NuGet dependencies with a Version attribute, and <ProjectReference> elements link to other projects within the same solution by relative path.

🏏

Cricket analogy: Like a team's official registration document listing its home ground, squad size limit, and sponsor logos, the .csproj's PropertyGroup declares the project's core settings such as target framework and nullable checking.

Organizing Multi-Project Solutions

A typical layered .NET solution splits into projects like MyApp.Api (the entry point, referencing ASP.NET Core), MyApp.Domain (plain C# entities and business rules with no external dependencies), MyApp.Infrastructure (Entity Framework Core, external service clients), and MyApp.Tests (xUnit tests referencing the others). dotnet sln add adds a project to the solution file, and dotnet new sln creates a new empty solution — the .sln file itself is just a manifest listing project paths and build configurations, not compiled code.

🏏

Cricket analogy: Like separating a franchise into its playing squad, coaching staff, and support/medical team as distinct functional units under one franchise umbrella, a solution separates Api, Domain, Infrastructure, and Tests projects under one solution.

xml
<!-- MyApp.Domain/MyApp.Domain.csproj -->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
</Project>

<!-- MyApp.Api/MyApp.Api.csproj -->
<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\MyApp.Domain\MyApp.Domain.csproj" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
  </ItemGroup>
</Project>

Run dotnet new sln -n MyApp then dotnet sln MyApp.sln add MyApp.Api/MyApp.Api.csproj MyApp.Domain/MyApp.Domain.csproj to build up a multi-project solution from the CLI without ever opening an IDE.

  • A .csproj file defines a single project's target framework, dependencies, and build settings in XML.
  • A .sln file is a manifest grouping one or more projects for unified building and versioning.
  • Modern SDK-style .csproj files are minimal — source files are included automatically by folder convention.
  • PackageReference declares NuGet dependencies; ProjectReference links to other projects in the same solution.
  • A common layered layout splits Api, Domain, Infrastructure, and Tests into separate projects.
  • dotnet new sln and dotnet sln add manage solutions entirely from the command line.
  • Microsoft.NET.Sdk.Web is used for ASP.NET Core projects; Microsoft.NET.Sdk for plain libraries and console apps.

Practice what you learned

Was this page helpful?

Topics covered

#NET#NETCoreStudyNotes#MicrosoftTechnologies#ProjectAndSolutionStructure#Project#Solution#Structure#Anatomy#StudyNotes#SkillVeris