Can't get a Hello World of RazorGenerator to do what I expect

Jun 17, 2013 at 12:33 AM
Hi all, this seems really basic, and perhaps I'm missing something, though I must have read Mr Ebbo's blog tens times now!

What I want is to deploy my razors views compiled (duh!) but without the actual razor view included. I want to do this so others can't modify the razor code at a later time or see just what I've done with them.

So I created an MVC4 web app, installed the extension, installed the razorgenerator.mvc nuget package, and for Index.cshtml:
  • Set Build Action property to None
  • Set Copy To Output Directory property to Do Not Copy
  • Set Custom Tool property to RazorGenerator
Immediately it creates the Index.generated.cs, as it should. Cool. So I run this in debug mode and it works just fine, showing the mvc template home page. Now when I publish this and put it onto my local IIS, I get the familiar:

"The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:..."

If I set the Build Action to Content it works just fine, but deploys Index.cshtml, which I don't want.

What have I missed here?
Jun 17, 2013 at 2:10 AM
Not sure. It's acting like the Razor view engine is not getting registered. Can you make sure you have the relevant code in your App_Start\RazorGeneratorMvcStart.cs?
Jun 17, 2013 at 3:23 AM
Ah, yes that looks like it. Something must have gone wrong with the nuget package and RazorGeneratorMvcStart.cs wasn't even there. Very odd.

Thank you very much sir!