dotnet-project-file-analyzers

Proj0020: Item group should only contain nodes of a single type

<ItemGroup> nodes should only contain nodes of a single type. Mixing nodes of different types in a single <ItemGroup> can become harder to read and maintain.

Non-compliant

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

  <ItemGroup>
    <PackageReference Include="FluentAssertions.Analyzers" Version="*" />
    <PackageReference Include="NUnit.Analyzers" Version="*" />
    <ProjectReference Include="..\..\src\DotNetProjectFile.Analyzers\DotNetProjectFile.Analyzers.csproj" />
  </ItemGroup>
  
</Project>

Compliant

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

  <ItemGroup>
    <PackageReference Include="FluentAssertions.Analyzers" Version="*" />
    <PackageReference Include="NUnit.Analyzers" Version="*" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\src\DotNetProjectFile.Analyzers\DotNetProjectFile.Analyzers.csproj" />
  </ItemGroup>

</Project>

Exceptions

Some node types may appear together (due the way they might be used together). Currently the set of node types that may appear together is the following:

Compile
EmbeddedResource
Content
None

More sets may be added over time.