HintPath vs Visual Studio中的ReferencePath [英] HintPath vs ReferencePath in Visual Studio

查看:792
本文介绍了HintPath vs Visual Studio中的ReferencePath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.csproj文件中的 HintPath 与<$ c中的 ReferencePath 之间的区别究竟是什么$ c> .csproj.user 文件?我们正在尝试提交一个约定,其中依赖性DLL位于发行版svn repo中,所有项目都指向特定版本。由于不同的开发人员具有不同的文件夹结构,相对引用将无法正常工作,因此我们提出了一种使用指向特定开发人员版本文件夹的环境变量创建绝对引用的方案。因此,在添加引用后,我们手动编辑项目文件,以使用环境变量将引用更改为绝对路径。

What exactly is the difference between the HintPath in a .csproj file and the ReferencePath in a .csproj.user file? We're trying to commit to a convention where dependency DLLs are in a "releases" svn repo and all projects point to a particular release. Since different developers have different folder structures, relative references won't work, so we came up with a scheme to use an environment variable pointing to the particular developer's releases folder to create an absolute reference. So after a reference is added, we manually edit the project file to change the reference to an absolute path using the environment variable.

我注意到这可以完成同时使用 HintPath ReferencePath ,但我们之间可以找到的唯一区别就是 HintPath 在构建时被解析,并且项目加载到IDE中时, ReferencePath 。我不知道那是什么后果。我注意到VS有时会重写 .csproj.user ,我必须重写 ReferencePath ,但我不知道是什么触发了。

I've noticed that this can be done with both the HintPath and the ReferencePath, but the only difference I could find between them is that HintPath is resolved at build-time and ReferencePath when the project is loaded into the IDE. I'm not really sure what the ramifications of that are though. I have noticed that VS sometimes rewrites the .csproj.user and I have to rewrite the ReferencePath, but I'm not sure what triggers that.

我听说最好不要检查 .csproj.user 文件,因为它是用户特定的,所以我想要的目标,但我也听说, HintPath 指定的DLL不是保证为如果相同的DLL是例如,加载位于项目的输出目录。任何想法?

I've heard that it's best not to check in the .csproj.user file since it's user-specific, so I'd like to aim for that, but I've also heard that the HintPath-specified DLL isn't "guaranteed" to be loaded if the same DLL is e.g. located in the project's output directory. Any thoughts on this?

推荐答案

根据这个MSDN博客: https://blogs.msdn.microsoft.com/manishagarwal/2005/ 09/28 / resolving-file-references-in-team-build-part-2 /

According to this MSDN blog: https://blogs.msdn.microsoft.com/manishagarwal/2005/09/28/resolving-file-references-in-team-build-part-2/

构建时有一个程序集的搜索顺序。搜索顺序如下:

There is a search order for assemblies when building. The search order is as follows:


  • 来自当前项目的文件 - 由$ {CandidateAssemblyFiles}指示。

  • 来自.user / targets文件的
  • $(ReferencePath)属性

  • %(HintPath)由参考项指定的元数据。

  • 目标框架目录

  • 在使用AssemblyFoldersEx注册的注册表中找到的目录。

  • 注册的汇编文件夹,由$ {AssemblyFolders}指示。

  • $(OutputPath)或$(OutDir)

  • GAC

  • Files from the current project – indicated by ${CandidateAssemblyFiles}.
  • $(ReferencePath) property that comes from .user/targets file.
  • %(HintPath) metadata indicated by reference item.
  • Target framework directory.
  • Directories found in registry that uses AssemblyFoldersEx Registration.
  • Registered assembly folders, indicated by ${AssemblyFolders}.
  • $(OutputPath) or $(OutDir)
  • GAC

因此,如果希望的程序集由 HintPath 找到,但是可以使用 ReferencePath 找到替代的程序集,那么它更喜欢参考路径'd程序集到 HintPath 'd。

So, if the desired assembly is found by HintPath, but an alternate assembly can be found using ReferencePath, it will prefer the ReferencePath'd assembly to the HintPath'd one.

这篇关于HintPath vs Visual Studio中的ReferencePath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆