HintPath VS ReferencePath在Visual Studio [英] HintPath vs ReferencePath in Visual Studio
问题描述
到底是什么在.csproj的文件和 ReferencePath
在<$ c中的 HintPath
之间的区别$ C> .csproj.user 文件?我们正在努力致力于公约,其中依赖的DLL文件是在一个版本的svn回购和所有项目指向一个特定版本。由于不同的开发商有不同的文件夹结构,相对引用将无法工作,所以我们想出了一个方案,以使用环境变量指向特定的开发者版本的文件夹下创建一个绝对的参考。所以在一个引用添加,我们手动编辑项目文件使用环境变量来改变基准为绝对路径。
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
在编译时得到解决, ReferencePath
时,该项目被装载到IDE中。我真的不知道什么的后果是虽然。我注意到,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
-specified 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博客<一href="http://blogs.msdn.com/manishagarwal/archive/2005/09/28/474769.aspx">http://blogs.msdn.com/manishagarwal/archive/2005/09/28/474769.aspx
有建筑物时,搜索顺序进行装配。搜索顺序如下:
There is a search order for assemblies when building. The search order is as follows:
- 文件从当前项目 - 由{CandidateAssemblyFiles}表示
- $(ReferencePath)属性来自。用户/目标文件。
- 将参照项目表明%(HintPath)的元数据。
- 目标框架目录。
- 在使用AssemblyFoldersEx登记注册表中找到目录。
- 在注册组件文件夹,用{} AssemblyFolders表示。
- $(OutputPath)或$(OUTDIR)
- 广汽
因此,如果所需的组件由HintPath发现,但备用组件可以使用ReferencePath中找到,将preFER的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 ReferencePath在Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!