Helixoft Blog

Peter Macej - lead developer of VSdocman - talks about Visual Studio tips and automation

Sharing a Source File Across Multiple Projects

"How can I share one source code file across several projects? I want to have this file on one place only and use it in multiple projects so when I modify it in one project, the changes get automatically reflected in all projects. When I add existing file to the project, a local copy is always created and used." This is the question that I answered many many times on various newsgroups. The answer is very simple:

  1. Go to menu Project - Add Existing Item...
  2. Select desired file and from drop-down menu on Open button (little triangle on the right side) select Link File.

    Link Shared File to VS project

    In VS 2005 this button is called Add and it has Add As Link option.

    Add shared file in VS 2005

This will only link existing file and will not create any local copy. It seems that Microsoft should change the way how to do it because so many VS users have this problem.

Comments

# Jon 2005-12-20 16:52
I don't see this option in VS 2005...anyone know how to do it in the new version?
# Peter Macej 2005-12-20 17:16
I can see it even in VS 2005. The button is called Add instead of Open. There is "Add As Link" option in its drop-down menu.

Comments are now closed for this entry

 

Start generating your .NET documentation now!
DOWNLOAD
Free, fully functional trial