.NET project file analyzers community

Proj0242: Generate NuGet packages conditionally

To ensure that packages are not interdependently shipped in DEBUG (or other) mode, a conditional statement should be defined on <GeneratePackageOnBuild> or any of it ancestor nodes. Doing so, NuGet’s artifacts are only generated during a RELEASE (or other intendend) build mode.

Non-compliant

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

  <PropertyGroup>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

</Project>

Compliant

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

  <PropertyGroup Condition="'$(Configuration)'=='Release'">
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
  </PropertyGroup>

</Project>