Proj0219: Packable projects should be libraries

Creating NuGet packages for project files other than libraries is unusual and often indicates a misconfiguration.

A known exception to this rule are .NET CLI tools packages. Because <PackAsTool> needs to be on true for this type of project, it can be excluded from the rule.

This rule reports on any project that is packable and not a library or an executable with the <PackAsTool> property on true.

If your project is the exception to this rule, you should disable this rule for the reported project.

Non-compliant

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

  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <IsPackable>true</IsPackable>
  </PropertyGroup>

</Project>

Compliant

<Project Sdk="Microsoft.NET.Sdk">
 
 <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Library</OutputType>
    <IsPackable>true</IsPackable>
  </PropertyGroup>

</Project>

or

<Project Sdk="Microsoft.NET.Sdk">
 
 <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <IsPackable>true</IsPackable>
    <PackAsTool>true</PackAsTool>
  </PropertyGroup>

</Project>