Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvcBuildViews seems to build more files than are included in the .csproj file

Is there any way to limit the view building to only files included in the .csproj file? Or is there at least a way to exclude certain folders from being built?

In our project folder structure we have an \Admin\Mocks folder which contains lots of mocked up .aspx and .cshtml files, and while the \Admin\Mocks folder isn't included in the .csproj file (though \Admin is), it seems that all the files in that tree are getting built. This of course generates LOTS of build errors.

I'm not sure that this makes a difference, but our project is a hybrid WebForms/Mvc3 application (both WebForms and Razor View Engines) using Asp.Net 4.

like image 428
Eric Amodio Avatar asked May 10 '11 14:05

Eric Amodio


2 Answers

Based on the time stamp I assume you eventually worked around this but I got here Googling for a solution to the same problem.

We have a bunch of old Webforms views that are only checked in (not referenced by the project) for reference purposes and for A/B testing while we are updating the application. (Webforms -> Razor, MVC2 -> MVC4, etc)

This was an issue as both the .cshtml and .aspx files were being built and the errors from the Webform views were breaking the build.

The solution for us was to rename the the old view files from Index.aspx to Index.aspx.old

(In your case I would suggest Index.aspx.mock ?)

This meant they were excluded from the MvcBuildViews = True processing, but were still easily accessible and able to be opened from Visual Studio.

The additional benefit is you can change the default open with for that extension to use the Webforms editor so you still get highlighting and all.

like image 166
Maurice Butler Avatar answered Nov 15 '22 10:11

Maurice Butler


If possible, create a separate web project and put the content you don't want to be built in there, making sure to set MVCBuildViews to false.

like image 41
Steven Striga Avatar answered Nov 15 '22 12:11

Steven Striga