Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - Resource (CSS/JS/Images) sharing between web projects [duplicate]

Possible Duplicate:
Handling common JavaScript files in Visual Studio 2010

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.)

like image 430
Overflew Avatar asked Jun 24 '09 23:06

Overflew


2 Answers

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.

like image 86
Chris Nicol Avatar answered Nov 09 '22 17:11

Chris Nicol


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!

like image 25
chris Avatar answered Nov 09 '22 17:11

chris