The <AssemblyAttribute>
item only works in SDK-based projects. So if you create an SDK-based .NET Framework csproj, it will work (do note this might clash with any existing AssemlyInfo.cs
if one exists). e.g.:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage" />
</ItemGroup>
</Project>
Otherwise, I worked on a similar situation a while back and created a drop-in replacement for the assembly info generation logic for non-SDK csproj, see https://github.com/dasMulli/AssemblyInfoGenerationSdk for that (do log issues if it doesn't work). Do note that you may need to disable some generation of e.g. Version attributes similar to SDK-style projects so it doesn't clas with existing AssemblyInfo.cs
files.