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.
<!-- 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 slnanddotnet sln addmanage 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
1. What file format defines a single .NET project's build settings?
2. What is the purpose of a .sln file?
3. Which element inside a .csproj declares a NuGet package dependency?
4. Which SDK attribute value is used for ASP.NET Core web projects?
5. How do modern SDK-style .csproj files typically include source .cs files?
Was this page helpful?
You May Also Like
.NET CLI Basics
How to use the dotnet command-line interface to scaffold, build, test, and publish .NET applications.
Target Frameworks and TFMs
Understanding Target Framework Monikers (TFMs) like net8.0 and netstandard2.0, and how to multi-target a .NET project.
What Is .NET Core?
An overview of .NET Core as Microsoft's open-source, cross-platform runtime and how it evolved into the unified modern .NET.
Related Reading
Related Study Notes in Microsoft Technologies
Browse all study notesWindows 10 / UWP Development Study Notes
.NET · 30 topics
Microsoft TechnologiesWindows Batch Scripting Study Notes
Batch · 30 topics
Microsoft TechnologiesMFC (Microsoft Foundation Classes) Study Notes
C++ · 30 topics
Microsoft TechnologiesSilverlight Study Notes
.NET · 30 topics
Microsoft TechnologiesXAML Study Notes
.NET · 30 topics
Microsoft TechnologiesWPF (Windows Presentation Foundation) Study Notes
.NET · 30 topics