</>
Plan du cours — 6/46

Le fichier .csproj

Débutant

Chaque projet a un fichier .csproj (format XML) qui décrit comment le compiler.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <RootNamespace>MonApi</RootNamespace>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
  </ItemGroup>

</Project>
  • TargetFramework : la version de .NET ciblée (net10.0).
  • Nullable : active les nullable reference types (le compilateur avertit si vous risquez un NullReferenceException).
  • ImplicitUsings : ajoute automatiquement les using les plus courants (System, System.Linq...).
  • Contrairement aux anciens projets .NET Framework, il n'y a plus besoin de lister chaque fichier .cs : tous les fichiers du dossier sont inclus automatiquement.