The MSBuild extension is trying to pre-compile *all* .cshtml files it can find under the project root, instead of just the ones that are in the project. This is a bit of a problem when working in a hybrid app where a CMS such as Umbraco is managing it's own razor templates in the same web application.<br /><br />(e.g. App_Data\TEMP\Razor folder is a cache folder used by umbraco and is not part of my MVC project)
Comments: Following your advice I was able to get it working by creating a new .targets file in the same folder as my .csproj with the following content: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <RazorSrcFiles Include="**\Views\**\*.cshtml" /> </ItemGroup> </Project> which was then imported into the webapp.csproj at the start of the file: <Import Project="CustomRazorGenPath.targets" /> Note that I had to do this in a new .targets file because otherwise VS2012 was treating the ItemGroup as a list of files to include in the project and every single .cshtml file was appearing twice in Solution Explorer! Thanks for your help.
Comments: Following your advice I was able to get it working by creating a new .targets file in the same folder as my .csproj with the following content: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <RazorSrcFiles Include="**\Views\**\*.cshtml" /> </ItemGroup> </Project> which was then imported into the webapp.csproj at the start of the file: <Import Project="CustomRazorGenPath.targets" /> Note that I had to do this in a new .targets file because otherwise VS2012 was treating the ItemGroup as a list of files to include in the project and every single .cshtml file was appearing twice in Solution Explorer! Thanks for your help.