.NET project file analyzers community

Proj1200: Exclude private assets as project file dependency

Private assets (such as analyzers) are package references that have an effect on compiling a .NET assembly, but are not needed by the compiled artifact. By marking them in the project file as private asset it will not become a runtime dependency, that is linked to a package, or shipped when publishing it.

Non-compliant

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

  <PackageReference Include="DotNetProjectFile.Analyzers" Version="*" />

</Project>

Compliant

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

  <PackageReference Include="DotNetProjectFile.Analyzers" Version="*" PrivateAssets="all" />

</Project>

or

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

  <PackageReference Include="DotNetProjectFile.Analyzers" Version="*">
    <PrivateAssets>all</PrivateAssets>
  </PackageReference>

</Project>