I have tried to follow the steps from Precompiling Razor views in ASP.NET MVC 3
I can see the view cs files in the "obj\CodeGen\
" folder
I changed the line
<Import Project="$(SolutionDir)\packages\RazorGenerator.MsBuild.1.5.0.0\tools\RazorGenerator.targets"/>
to
<Import Project="$(SolutionDir)\packages\RazorGenerator.MsBuild.2.4.4\tools\RazorGenerator.targets"/>
so it matches the version that is there.
There is NO "RazorGenerator.targets
" file!
I have also read the project's wiki pages and anything I could find related to RazorGenerator on the net, but not sure what the next steps are suppose to be.
How do people actually use this?
I never actually tweaked the project file to get the RazorGenerator.MsBuild to work. When I installed the package it handled that for me.
I did check and my import statement also contains a condition attribute
Condition="Exists('..\..\..\packages\RazorGenerator.MsBuild.2.4.4\build\RazorGenerator.MsBuild.targets')"
Maybe try unregistering and reregistering the package. Also, I am assuming that you do have a valid razorgenerator.directives file at the root of your templates folder. Mine contains the following settings but refer to wiki for options and effects.
@*
Generator: Template
GenerateAbsolutePathLinePragmas: true
GeneratePrettyNames: true
TrimLeadingUnderscores: true
*@
You don't need to set the Custom Tool with the msbuild variant of RazorGenerator. Just compile and you will see the obj directory of your solution populate with a CodeGen | Templates folder. There you can view the .cs backing partial classes created by RazorGenerator.