views:

126

answers:

2

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.

A: 

Add existing item is used to add a copy to the project in Visual Studio

Ravia
I thought so initially as well. However, in my Visual Studio 2003, this is not the case strangely enough. I am trying to figure out why.
Andy
+1  A: 

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.

http://msdn.microsoft.com/en-us/library/9f4t9t92.aspx

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)."

http://blogs.msdn.com/jjameson/archive/2009/04/02/linked-files-in-visual-studio-solutions.aspx

fupsduck
I do not have this in my Visual Studio 2003. When I click on the open button drop-down list, there are only two options: "Open" and "Open With". There was no "Add As Link" option.
Andy
Just to add, the link you gave me was for Visual Studio 2008! So probably 2003 does not have this functionality.
Andy
That answers the question then. I have no option but to manually edit the project file. Thank you very much for the help.
Andy