Iris Classon
Iris Classon - In Love with Code

Sharing files across projects by linking in VS

This is not a new feature, but something not all.Net devs are aware of, you can share files from one project to another by linking the file in directly. Let me demonstrate, create two projects in a solution, and create a file with whatever you want shared. Add this file to just one of the projects. On the other project right click and select Add => existing item. Find the file, and click on the dropdown arrow and select add as link. Thats it. Really.

The file we are linking in

The file we are linking in

adding the file

Look, it works :)

Whenever you add a change to the file it will be updated, no matter which project you are in. It is just referenced in, not copied as when you simply select Add.


Leave a comment below, or by email.
11/16/2012 5:32:03 AM
Unfortunately JavaScript files can't be linked using this technique. See for more info 
11/16/2012 11:31:54 AM
I'm using Razor Generator and I'm linking files this way to separate controllers and models from the views. Actually, have them in a complete different project. 
3/15/2013 7:34:32 AM
I saw linked files in projects before be didn't know how it was done.   That is a real shame because I've been programming about as long as you have been alive.  Shame on me and thanks! 

Last modified on 2012-11-14

comments powered by Disqus