In .NET Core 2 Web API app, Publish to folder feature in MS VS 2017 produce:
.PrecompiledViews.dll
.PrecompiledView
You are right, the precompile step always emits an assembly and doesn't check if there are actually views. You can disable the precompilation step by putting this into your csproj file:
<PropertyGroup>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>
This will then activate the normal copilation context preservation (refs
subfolder). To deactivate this as well, add
<PreserveCompilationContext>false</PreserveCompilationContext>
to the property group.