Proj0401: Only publish executables
With executing dotnet publish
the application and its dependencies to a
folder for deployment to a hosting system. Executing dotnet publish
on a
project with another output type than exe
or winexe
. As a result this
rule will advise to set <IsPublishable>
to false
.
More info
can be found here.
Non-compliant
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<IsPublishable>true</IsPublishable>
<OutputType>Library</OutputType>
</PropertyGroup>
</Project>
Compliant
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<IsPublishable>false</IsPublishable>
<OutputType>Library</OutputType>
</PropertyGroup>
</Project>