I think there is a Catch-22 when using Package Restore and the packages folder is not checked in. The initial install of RazorGenerator.MsBuild adds the "..\packages\**\tools\NuGet.import.targets" import to NuGet.targets, but when the packages folder is not checked in, the RazorGenerator NuGet.import.targets file does not yet exist when the build is initiated. Package restore pulls down the RazorGenerator.MsBuild package, which brings in the import targets file, but I think it it is too late in the build process.
This can be reproduced by installing the RazorGenerator.MsBuild package, deleting the packages folder, and then building the solution - view the build output at normal verbosity and verify that the PrecompileRazorFiles target is never invoked.
One potential solution is for the NuGet installation to add the RazorGenerator.targets file directly to the MVC project itself - then package restore is only responsible for pulling down the binaries.
This can be reproduced by installing the RazorGenerator.MsBuild package, deleting the packages folder, and then building the solution - view the build output at normal verbosity and verify that the PrecompileRazorFiles target is never invoked.
One potential solution is for the NuGet installation to add the RazorGenerator.targets file directly to the MVC project itself - then package restore is only responsible for pulling down the binaries.