.NET project file analyzers community

Proj0013: Include package references only once

A <PackageReference> should only be defined once per package. If (for whatever reason) an update is needed in project file, the Update attribute should be used. Update are only allowed in different files.

Non-compliant

common.props

<Project>

  <ItemGroup>
    <PackageReference Include="Qowaiv" Version="6.0.0" />
  </ItemGroup>
  
</Project>

project.csproj

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

  <ItemGroup>
    <PackageReference Include="Qowaiv" Version="6.4.2" />
    <PackageReference Include="serilog" Version="2.10.0" />
    <PackageReference Include="serilog" Version="3.0.1" />
  </ItemGroup>
  
</Project>

Compliant

common.props

<Project>

  <ItemGroup>
    <PackageReference Include="Qowaiv" Version="6.0.0" />
  </ItemGroup>
  
</Project>

project.csproj

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

  <ItemGroup>
    <PackageReference Update="Qowaiv" Version="6.4.2" />
    <PackageReference Include="serilog" Version="3.0.1" />
  </ItemGroup>
  
</Project>