How do I share common JS files between multiple so

2019-06-01 18:01发布

问题:

I currently have two MVC projects in two solutions which will share a fair bit of look and feel but very different functionality. As such they have different solutions to manage their code. Everything is being stored in TFS repositories.

Currently any shared C# code is managed through class libraries and while this is great for the C# code there doesn't appear to be a similar way to do this for JavaScript or CSS files. Is there a best practices way to handle shared JS and CSS files between separate solutions in TFS specifically or just in solution files in general?

To be clear what I mean when I say "shared," it should have the following criteria:

  1. File has the same name in both solutions.
  2. Editing the file in solution A results in those changes being applied to that file in solution B.
  3. Ideally this will be transparent to the developer.

回答1:

You can create a separate project (say "CommonJsCss") that contains all of the shared .js and .css files. Then just include that project in both Solution A and Solution B.



回答2:

why don´t you put your files in a folder, let´s say 'c:\myprojects\shared\javascripts' and include the folder in all the solutions you need it to be? all code changes will be usable for the other project. Also, you can define your own bundles in each solution including those files.