Nov 142012
 
 November 14, 2012  Posted by at 10:15 am Dev Environment, Uncategorized  Add comments

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

The file we are linking in

The file we are linking in

adding the file

adding the file

Look, it works :)

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.

  3 Responses to “Sharing files across projects by linking in VS”

  1. Unfortunately JavaScript files can’t be linked using this technique. See http://stackoverflow.com/questions/6107464/handling-common-javascript-files-in-visual-studio-2010 for more info

  2. 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. 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!

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 13 + 4 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)