.NET project file analyzers community

Proj0807: Use Directory.Packages.props only for Central Package Management

When using Central Package Management the central Directory.Packages.props file should only contain settings that are related to CPM. Although it will work otherwise, it is counter-intuitive and recipe for disaster.

Non-compliant

<?xml version="1.0" encoding="utf-8"?>
<Project>

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <OutputType>Library</OutputType>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
    <CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled>
  </PropertyGroup>

  <ItemGroup>
    <PackageVersion Include="Qowaiv" Version="7.0.0" />
    <PackageVersion Include="PolySharp" Version="1.14.1" />
  </ItemGroup>
  
  <ItemGroup>
    <GlobalPackageReference Include="System.Text.Json" Vesion="8.0.4" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Include="PolySharp" PrivateAssets="all" />
  </ItemGroup>
  
  <ItemGroup>
    <AdditionalFiles Include="Directory.Packages.props" Link="Properties/Directory.Packages.props" />
    <AdditionalFiles Include="*.ts" />
  </ItemGroup>

</Project>

Compliant

<?xml version="1.0" encoding="utf-8"?>
<Project>

  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <CentralPackageFloatingVersionsEnabled>true</CentralPackageFloatingVersionsEnabled>
    <CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
    <CentralPackageVersionOverrideEnabled>true</CentralPackageVersionOverrideEnabled>
  </PropertyGroup>

  <ItemGroup>
    <PackageVersion Include="Qowaiv" Version="7.0.0" />
    <PackageVersion Include="PolySharp" Version="1.14.1" />
  </ItemGroup>
  
  <ItemGroup>
    <GlobalPackageReference Include="System.Text.Json" Vesion="8.0.4" />
  </ItemGroup>
  
  <ItemGroup>
    <AdditionalFiles Include="Directory.Packages.props" Link="Properties/Directory.Packages.props" />
  </ItemGroup>

</Project>