Search code examples
visual-studio-2008projects-and-solutions

How to add static content that needs to be shared between projects in a Visual Studio Solution


I have a C# Solution that includes several websites. Those websites have some communal data (e.g. images and shared jQuery extensions). Currently the data is included in each Project. Obviously we're running into sync problems and as those data directories are becoming larger, we're moving more and more data around. We could hard encode links to where the data really resides on the production server but I think we'd like to avoid that (not to mention that we use the embedded cassini server for our testing and such and I've no idea how smoothly that would work). Is there something I've overlooked for a portable and maintainable way to do this?

Clarification: The contents that needs to be shared are located in directories (i.e. images/, js/)


Solution

  • You can add those files to the project as linked files - that way they are not physically copied into the project's directory but are still included in the project. You can just worry about maintaining one folder's worth of static content and know that whenever you build your solutions you will be using the version from that folder.

    To add a linked file in Visual Studio, right click the project, hit add->existing file, then in the select file dialog hit the little drop down arrow next to the "add" button and pick "Add as link".