dotnet 7 exclude a dll from coverage report

If you want to exclude a dll or a project to be excluded from the code coverage report of dotnet test command then you need to add the following code in the project file of your project which you want to be excluded:

    <AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />

dotnet test command will not exclude that dll now from the code coverage results.