Build/Test Issues

NCrunch Build fails when building MVC views

Started by simonl on 7,533 views

The build fails if an MVC web project is set to build views, and a view references a dependency in a project reference.

To recreate:
Create a new MVC 3 project, called MvcApplication1
Create a new ClassLibrary project, called ClassLibrary1
Add a project reference to ClassLibrary1 from MvcApplication1
Enable NCrunch
Edit MvcApplication1.csproj to change the line:
<MvcBuildViews>false</MvcBuildViews>
to
<MvcBuildViews>true</MvcBuildViews>
(at this point it should still be building)
Edit \Views\Home\Index.cshtml, adding the line @using ClassLibrary1 at the top of the view.

NCrunch build now fails with@
c:\Users\XXXXX\AppData\Local\NCrunch\8528\15\MvcApplication1\Views\Home\Index.cshtml (2): The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)

My guess is that something funny is going on with the aspnet_compiler not finding the project dependency.

Any way of fixing this?

Thanks,
Simon.

Edited

Hi Simon,

Thanks for reporting this. It looks as though the MVC web compiler is expecting the dependencies to be in the same directory as the web project at build time. You should be able to solve this issue by turning on the CopyReferencedAssembliesToWorkspace for your web project. I'll make a note to adjust a future revision of NCrunch to do this automatically so it's a bit less confusing.


Cheers,

Remco
Great thanks Remco, that has fixed the problem. Sorry, I had spotted that option earlier but forgot to try it!

Cheers for the quick response.

Simon.

Post a reply

Log in to reply.