.NET project file analyzers community

Proj0450: Test projects should not be packable

Test projects should only be responsible for running tests. Hence if they do create a (NuGet) package, that is most likely unintended, and wrong.

Non-compliant

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

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <IsTestProject>true</IsTestProject>
    <IsPackable>true</IsPackable>
  </PropertyGroup>

  <ItemGroup Label="Build tools">
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" PrivateAssets="all" />
  </ItemGroup>
  
</Project>

Compliant

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

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <IsTestProject>true</IsTestProject>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup Label="Build tools">
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" PrivateAssets="all" />
  </ItemGroup>
  
</Project>