Compile views including MvcBuildViews in the MVC 2 portable scope

I have a large .net mvc 2 project where we use the MvcContrib Portable Area. There is a main website on which many modules (PA modules) are downloaded.

The main application contains Site.Mater in its ~\Views\Shared folder. Each module also has its own Site.Master , which inherits from this core.

We are currently using something like:

 <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" MasterPageFile="~/Views/Shared/Site.Master" %> 

After compilation, the view processes the main Site.Master right, since this is a relative path. Now I got a requirement for creating views at compile time. So I included MvcBuildViews = true in every PA web module project.

Of course, I get errors saying "/temp/Views/Shared/Site.Master is not found" .

How to save a portable region with embedded content and make sure that the views are error free?

Any idea?

+4
source share
2 answers

You can not.

I am dealing with the same problem and you cannot easily fake the physical location of the file.

The only solution is to make a placeholder and delete the inline placeholder file as part of the build process. The advantage of this method is that a non-embedded resource will load faster during development.

Another thing to keep in mind is that loading your views as embedded resources is pretty slow. When your build process moves centralized "general" views to a local project, this will lead to better performance for your users.

+2
source

if you just want to make sure everything is working fine, you can use Watin and write some unit tests that will test this

+1
source

All Articles