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.
Comments: This gets trickier. The RazorGenerator target depends on the msbuild task in the assembly both of which need to be present at the time the target gets loaded. Even if the target ends up in the project, you'll need to have the assembly checked in alongside for it to work which would defeat the purpose of package restore. I haven't followed up with any of the MsBuild experts I guess now's a good time to do that.
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.
Comments: This gets trickier. The RazorGenerator target depends on the msbuild task in the assembly both of which need to be present at the time the target gets loaded. Even if the target ends up in the project, you'll need to have the assembly checked in alongside for it to work which would defeat the purpose of package restore. I haven't followed up with any of the MsBuild experts I guess now's a good time to do that.