Visual Studio:相对程序集引用路径

编程入门 行业动态 更新时间:2024-10-28 08:22:26
本文介绍了Visual Studio:相对程序集引用路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

解决方案

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

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

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

    ..\..\myReferences\myDLL.dll

  • 现在引用 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:

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

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

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

    Hope this helps.

    更多推荐

    Visual Studio:相对程序集引用路径

    本文发布于:2023-11-11 21:35:35,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1579614.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:路径   程序   Visual   Studio

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!