本文介绍了Visual Studio:相对程序集引用路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在解决方案目录中添加对程序集的引用时,有什么方法可以相对添加它,以便在检入和检出存储库时在项目中正确引用它?

解决方案

扩展 Pavel Minaev 的原始评论 - Visual Studio 的 GUI 支持相对引用,并假设您的 .sln 是相对引用的根.因此,如果您有解决方案 C:\myProj\myProj.sln,则您在 C:\myProj\ 的子文件夹中添加的任何引用都会自动添加为相对引用.>

要在单独的目录中添加相对引用,例如 C:/myReferences/myDLL.dll,请执行以下操作:

  1. 在解决方案资源管理器中右键单击项目并选择添加引用...
  2. ,在 Visual Studio GUI 中添加引用
  3. 找到此引用所在的 *.csproj 并在文本编辑器中打开它
  4. 编辑 <HintPath > 等于

现在引用 C:\myReferences\myDLL.dll.

希望这会有所帮助.

When adding a reference to an assembly located within the solution directory, is there any way to add it relatively, so that when checked in and out of a repository it is referenced in projects correctly?

解决方案

To expand upon Pavel Minaev's original comment - The GUI for Visual Studio supports relative references with the assumption that your .sln is the root of the relative reference. So if you have a solution C:\myProj\myProj.sln, any references you add in subfolders of C:\myProj\ are automatically added as relative references.

To add a relative reference in a separate directory, such as C:/myReferences/myDLL.dll, do the following:

  1. Add the reference in Visual Studio GUI by right-clicking the project in Solution Explorer and selecting Add Reference...
  2. Find the *.csproj where this reference exist and open it in a text editor
  3. Edit the < HintPath > to be equal to

    <HintPath>..\..\myReferences\myDLL.dll</HintPath>

This now references C:\myReferences\myDLL.dll.

Hope this helps.

这篇关于Visual Studio:相对程序集引用路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 17:44