3

One of the systems I currently work on has a number of solutions, each with a single MVC UI project (see below for an example layout). Most of the UI projects share a fair amount of JavaScript and CSS. At the moment, we're currently copying and merging any changes that are made to the common JS across each UI project (again, in different solutions), which is not ideal.

Here's a simplified view of some of the solutions:

Solution1
-- Solution1-UI
   -- Scripts directory (includes both shared JS and JS specific to this UI project)
Solution2 solution
-- Solution2-UI
   -- Scripts directory (includes both shared JS and JS specific to this UI project)
Solution3 solution
-- Solution3-UI
   -- Scripts directory (includes both shared JS and JS specific to this UI project)
... other solutiuons with the same issue

What I'd ideally like to do is create a common solution or package (or something) which can contain the common JS and can be referenced by all of the affected solutions (Solution1, Solution2, etc.).

A quick search shows that it can be done if the projects are in the same solution (i.e. How do you share scripts among multiple projects in one solution?), but our use case is a little different.

What are some of the accepted ways of achieving this?

Jamie Taylor
  • 1,644
  • 1
  • 18
  • 42

1 Answers1

1

In this case you will need to have your own CDN, you will create a separate website which deliver your JS files though URLs and your other solutions just reference these URLs.

In your solutions you will reference these scripts the same as you do with jquery CDN for example, but with your own URLs coming from the common website solution you created.

Another solution I can think about is just upload your script to a service like amazon s3 or google cloud and get reference to these files from there.

Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301