我可以在Visual Studio 2003中添加文件并使其指向另一个项目中的现有文件吗?

时间:2010-02-01 10:07:39

标签: c++ visual-studio-2003

这是一个关于使用Visual Studio 2003的问题。抱歉,这不是一个严格的编程问题,但它确实会以一种相当烦人的方式影响我的工作。

我有一个包含3个不同项目的解决方案(比方说MyProgram,UnitTest和PerformanceTest),并且有一个文件(比如myclass.h)需要在3个项目之间共享。

该文件在MyProgram项目中创建,现在我想将其添加到其他项目中。

假设我转到解决方案资源管理器,右键单击UnitTest,然后选择Add - >从弹出菜单中添加现有项目。

文件myclass.h已添加到项目中,但不是指向现有的(解决方案目录)\ MyProgram \ myclass.h,而是在(solution directory)\ UnitTest \ myclass.h中创建一个新文件。现在这意味着每次我更改\ MyProgram \ myclass.h时,我需要将其复制到\ UnitTest \ myclass.h或文件不是最新的。

这是Visual Studio 2003的“功能”还是我的选项/设置有问题?手动编辑.vcproj文件是使链接指向现有文件的唯一方法吗?非常感谢你的帮助。

2 个答案:

答案 0 :(得分:1)

尝试此操作 - 创建指向现有项目的链接:

1.在解决方案资源管理器中,选择目标项目。 2.在“项目”菜单上,选择“添加现有项”。 3.在“添加现有项”对话框中,找到并选择要链接的项目项。 4.从“打开”按钮下拉列表中,选择“添加为链接”。

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

你的权利 - 即2008年。这个链接意味着你想要做的是在VS 2005中引入的,并且在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

答案 1 :(得分:0)

添加现有项目用于在Visual Studio

中向项目添加副本