Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1007 Bytes

File metadata and controls

42 lines (33 loc) · 1007 Bytes
parent ancestor
Test Projects
Rules

Proj0451: Test projects should not be publishable

Test projects should only be responsible for running tests. Hence if they can be published, that is most likely unintended, and wrong.

Non-compliant

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

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <IsTestProject>true</IsTestProject>
    <IsPublishable>true</IsPublishable>
  </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>
    <IsPublishable>false</IsPublishable>
  </PropertyGroup>

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