I have a .NET Core application which has got one .NET Standard 2.1 project in it. I am using Coverlet to get the code coverage in Cobertura format.
I am using "coverlet.msbuild" nuget package in all my Test projects.
I want to add [ExcludeFromCodeCoverage]
attribute at a assembly-level so that coverlet ignores this project while performing the analysis.
I cannot find the AssemblyInfo.cs
file in .NET Core / .NET Standard projects.
I tried adding the below tag in the project's .csproj
file
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
</ItemGroup>
but still no luck.
The only workaround for me is to add thr [ExcludeFromCodeCoverage]
attribute manually in all the class files which is not the best way.
This worked for .NET 6. I suspect it will work for .NET Core 3.1+
Add the following to the csproj file
Or this in any file in the project for the assembly