There are also a few things you can do in the csproj files to make sure the files aren’t picked up:
1) Make sure none of the globbing patterns that look for “project items” pick up the files:
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);your_nonproj.file;a\**\*.pattern</DefaultItemExcludes>
</PropertyGroup>
2) Remove items explicitly:
<ItemGroup>
<None Remove="hidden.file" />
<Content Remove="wwwroot\lib\**\*" />
</ItemGroup>
Note that, on large directories (number of files), using DefaultItemExcludes with the folder\** pattern is a lot faster since msbuild will skip walking the directory entirely. Using a remove for this will still let msbuild spend quite some time discovering files.