I've had the same requirement before and this is how I dealt with it:
Move your shared content
In my solution, I added a new Shared folder and created a Shared project. You don't necessarily have to move into a new project, I just did this because the shared project also included shared MVC logic.
Add linked shared files to the solutions
It's important to know that this step is optional, it's just that it helps developers in that the files are still in the expected place. Now that you have for example: Project1, Project2 and Shared. Now in Project1 (for example), add your files back in individually. But follow these steps:
- Right click the folder you wish to add the file to
- Hover over
Add then select Existing Item
- Navigate to the file in the
Shared project and select the file
- Before clicking 'Add`, notice the arrow
- Click this, and select
Add as Link
The benefit of this is that when you click on the file in your solution explorer within Project2, it will open the file in Shared.
Add pre-build events
In each project using the Shared files you will need to add Pre Build Events. Currently, although the project contains a reference to the shared file, it won't actually do anything when you run the project. The solution to this is build events:
- Right click your project and select
Properties
- Select
Build Events in the menu
In the Pre-build event command line section enter the following:
xcopy /R /E /Y "$(SolutionDir)SharedProject\Scripts" "$(ProjectDir)Scripts"
To explain: this will copy the contents of your scripts directory in your shared project, and add it to (or replace) your current projects scripts directory. You will need to add a line for each folder (e.g. HTML, CSS, etc)