Is there a way to work with a portable area content files without repetitive compilation?

61 views
Skip to first unread message

jrboelens

unread,
Apr 25, 2011, 9:37:29 AM4/25/11
to mvccontrib-discuss
I have a fairly simple portable area (PA) housed within another web
project. The PA exists in a different solution than the parent. A
fake parent application was added to the PA's solution in order to
work with the PA.

As per Poratble Area requirements, all of the files within the PA have
their Build Action's set to Embedded Resource. As such, changes to
content files (css, js, aspx, ascx, etc) now require compilation in
order to test.

Incurring repetitive compilation in order to CSS or Javascript files
significantly slows development time.

Has anyone come up with an easy way to use a PA directly? Or maybe
even it's files directly.

I have considered creating another web site that linked directly to
all of the files within the PA. Another thought was to create a
script that could modify the project file by flipping the Build
Actions to Content, then back to Embedded Resource on a while.

It feels as if I am missing the obvious solution to this problem. It
seems as if this would be a common problem for anyone using a Portable
Area.


jrboelens

unread,
May 24, 2011, 9:33:56 AM5/24/11
to mvccontrib-discuss
MvcContrib uses it's own VirtualPathProvider called
AssemblyResourceProvider. This provider can not only use embedded
resources, but also maintains the ability to reference physical files
adhering to the standard MVC Area naming convention.

The existence of a file will ensure that the file's contents be
rendered rather than the associated embedded resource.

The goal is to simply prevent the recompilation of the portable area
and it's harness when making content changes

We can achieve this with some simple IIS trickery.

Let us assume we have two projects, PortableArea and
PortableAreaHarness. Let us also assume that the name of the area is
'foo'.

We setup an IIS Site (localhost:5555) and point it at the root of
PortableAreaHarness.

At this point, the VirtualPathProvider will search for files in
PortableAreaHarness/Areas/foo before hitting the embedded resources in
the PortabelArea assembly.

Now we create a virtual directory in ~/Areas name foo. This will
allow the VirtualFileProvider to resolve the physical files.

That's it. Now you can make changes to any content file in
PortableArea without having to recompile.

If you want to specifically test the assembly's embedded resources,
simply remove the virtual directory and put it back when you're done
testing.
Reply all
Reply to author
Forward
0 new messages