.NET Core Documentation

Overview

The .csproj file is the heart of every .NET Core project. It defines the project's SDK, target framework, dependencies, build settings, and more. Modern .NET Core uses the SDK‑style format which is concise, XML‑based, and highly extensible.

The .csproj file

A typical SDK‑style project file looks like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
  </ItemGroup>
</Project>

The file is automatically processed by the .NET SDK during build and publish operations.

SDK‑style projects

Key advantages:

  • Implicit inclusion of *.cs files – no need to list each source file.
  • Convention‑based defaults (e.g., bin/Debug output).
  • Simple NuGet package references with PackageReference.
  • Multi‑targeting support with a single file.

Common Elements

ElementPurpose
<TargetFramework>Specifies the .NET version (e.g., net8.0, net7.0).
<OutputType>Defines output: Exe for apps, Library for DLLs.
<PackageReference>Adds NuGet packages.
<ProjectReference>References other .csproj files.
<Nullable>Enables nullable reference types.
<AssemblyName>Custom name for the output assembly.

Examples

Multi‑targeting

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0;net6.0</TargetFrameworks>
  </PropertyGroup>
</Project>

Conditional PackageReference

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
  <PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
</ItemGroup>

Reference guide

For a complete list of available project file elements, see the official Project File Reference.

Need help with a specific scenario? Check out the troubleshooting guide.