I believe I read somewhere there is a setting in one of the project files that will allow you to compile the .cshtml files when building your Visual Studio proj
.cshtml
Besides the true setting, you still need to ensure below setting is active in your csproj: