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

Posted

技术标签:

【中文标题】我可以在 Visual Studio 2003 中添加文件并使其指向另一个项目中的现有文件吗?【英文标题】:Can I add file in Visual Studio 2003 and make it point to an existing file in another project? 【发布时间】:2010-02-01 10:07:38 【问题描述】:

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

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

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

假设我进入解决方案资源管理器,右键单击 UnitTest,然后从弹出菜单中选择 Add -> Add Existing Item。

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

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

【问题讨论】:

【参考方案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

【讨论】:

我的 Visual Studio 2003 中没有这个。当我单击打开按钮下拉列表时,只有两个选项:“打开”和“打开方式”。没有“添加为链接”选项。 只是补充一下,你给我的链接是 Visual Studio 2008 的!所以可能2003没有这个功能。 那回答了这个问题。我别无选择,只能手动编辑项目文件。非常感谢您的帮助。【参考方案2】:

添加现有项用于在 Visual Studio 中向项目添加副本

【讨论】:

我一开始也是这么想的。然而,在我的 Visual Studio 2003 中,这并不奇怪。我正试图找出原因。

以上是关于我可以在 Visual Studio 2003 中添加文件并使其指向另一个项目中的现有文件吗?的主要内容,如果未能解决你的问题,请参考以下文章

我可以在 ms windows server 2008 上托管在 ms visual studio 2003 中开发的应用程序吗?

在 Visual Studio 2003 中使用 ELMAH

Visual Studio 2003 没有重建,我可以只建一个 dll 并将其传输到服务器吗?

VB.NET - Visual Studio 2003 的“继续”的替代方案

Visual Studio 2003 生产力技巧

如何在 Visual Studio 2003 中删除工作区?