C++ – add file in Visual Studio 2003 and make it point to an existing file in another project


This is a question about using Visual Studio 2003. Sorry it is not strictly a programming question but it does affect my work in a rather annoying way.

I have a solution with 3 different projects (let's say MyProgram, UnitTest and PerformanceTest), and there is a file (let's say myclass.h) which needs to be shared between the 3 projects.

The file is created in the MyProgram project and now I want to add it to the others.

Say I go to the solution explorer, right click on UnitTest, and select Add -> Add Existing Item from the pop-up menu.

The file myclass.h was added to the project, but instead of pointing to the existing (solution directory)\MyProgram\myclass.h, a new file is created in (solution directory)\UnitTest\myclass.h. Now this means that everytime I change \MyProgram\myclass.h, I need to copy it to \UnitTest\myclass.h or the file is not up to date.

Is this a "feature" of Visual Studio 2003 or have I got something wrong with the options/settings? Is manually editing the .vcproj files the only way to make the links point to an existing file? Thank you very much for your help.

Best Solution

Try this - To create a link to an existing item:

1.In Solution Explorer, select the target project. 2.On the Project menu, select Add Existing Item. 3.In the Add Existing Item dialog box, locate and select the project item you want to link. 4.From the Open button drop-down list, select Add As Link.


Your right - that is 2008. This link implies what you want to do was introduced in VS 2005 and is not available in 2003:

"Back in the days of the original Visual Studio .NET and the following version,
Visual Studio .NET 2003, whenever you added an existing file to a project,
it copied the file into the corresponding location in the project.

However, in Visual Studio 2005, the Add Existing Item feature provided the
ability to choose to either Add the item or Add As Link (via the little down
arrow on the button in the dialog box)."


Related Question