Originally posted at StackOverflow, but there seems no way to control this. So I'm adding as a feature request. Thank you.
I'm using RazorPages (on ASP.NET Core 6) and "css isolation". The css files are generated at obj/{Debug,Release}/net6.0/scopedcss/Pages/, and are included when performing a dotnet publish.
I also use Webpack, so I don't need to publish those css files (they are already bundled by Webpack).
I added variations of all of these to my Project.csproj without success:
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Content Remove="obj/*/*/scopedcss/**/*" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Content Remove="*.cshtml.rz.scp.css" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<None Remove="obj/*/*/scopedcss/**/*" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Compile Remove="*.cshtml.rz.scp.css" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)'=='Release'">
<PublishedFiles Remove="obj/*/*/scopedcss/**/*" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DefaultItemExcludes>$(DefaultItemExcludes);obj/*/*/scopedcss/**/*</DefaultItemExcludes>
</PropertyGroup>
These (and variations of them in every combination) did not work.
Please provide a way to exclude css isolation assets from dotnet publish.
My non-ideal workaround is to delete the files after publish:
<Target Name="DeleteScopedCss" AfterTargets="AfterPublish">
<RemoveDir Directories="$(PublishUrl)/wwwroot/Pages" />
</Target>