Build/Test Issues

NCrunch and RazorGenerator.MsBuild

Started by djanosik on 8,788 views

Hi,

I use RazorGenerator.MsBuild to precompile Razor views in my application. The main project will not compile with NCrunch (2.x). The following exception is thrown:
The "RazorCodeGen" task could not be loaded from the assembly... Could not load file or assembly...

I can fix this by specifying additional files to include (packages\RazorGenerator.MsBuild.2.2.2\tools\**.*). The assembly is correctly loaded, but there are some errors in precompiled views.
The type or namespace name 'TypeFromReferencedProject' could not be found (are you missing a using directive or assembly reference?)

I am not able to fix this. Can you help me?

Thank you!

Dusan
Hi Dusan -

Thanks for posting!

Most likely the precompiler requires that referenced assemblies exist in the output directory of the web application's DLL file. You can fix this by turning on the 'Copy referenced assemblies to workspace' project-level configuration setting for all the projects involved.

Note that this will incur a fairly significant performance penalty when building your project. You may want to weigh up the value of the precompiler when working with NCrunch - it may be worth disabling it for NCrunch builds by making the RazorGenerator build task conditional on NCrunch not being responsible for the build.
Thank you! It works now.
Excellent. Thanks!

Post a reply

Log in to reply.