views:

429

answers:

3

Hi there.

I'm looking to share a common pool of web resources (css/js/images) across multiple web projects. What I'm hoping to do, is create one project file for the resources, e.g.: Common.WebResources, and include it in the Visual Studio solutions for Site1 & Site2.

The part I'm looking to solve is setting it up to work with the VS Development Server (the one that gets fired up on F5), and any outer deployment concerns.

So we're hoping to wind up with the following projects mapped to the following web directories:

  • Site1.Web - /
  • Common.WebResources - /resources

In IIS, it would just be a virtual directory. So far with VS Development Server, I've only been able to:

  • Get them to deploy on different ports (not a lot of use)
  • Add a post-build event to copy the contents of /resources into Site1.Web

My questions are:

  • What other options are there?
  • Which do you feel to be the most appropriate, usable & maintainable?

(The reason I'd like the resources in a single, separate project is to avoid having to constantly merge a master resources location into each of the consuming sites, and merging back from each fix we make.)

+2  A: 

You can create a second Web.Resources project for the second site, but link the files from the first resource. I know this means that you have an extra project, but in a way it's good because you have abstract the resources, but still maintained a certain level of separation.

To link files go .... Add--> Existing Item --> Select file(s) --> Beside "Add" there is a down arrow --> Click "Add As Link".

Hope this helps.

Chris Nicol
+2  A: 

Unfortunately, this is one place where VS seems to fall down - I've been struggling with a similar problem.

One option you can try is to keep your resources in a separate, source controlled directory, and have a pre-build step that makes sure that there's a current copy in a directory visible, but not part of, the solution.

There are lots of drawbacks to this - you'll probably get warnings about missing css classes, and I'm not sure if javascript intellisense will be enabled, so if you do find a resolution, make sure you update your question!

chris
+2  A: 

I sure would like to know the answer to this. I certainly would have thought this was a no-brainer, but it appears not to be. This should be a common requirement. How does everyone else handle this????

Breadtruck