为什么 Visual Studio 在编辑项目时会从 AssemblyReferencerelativePath 中删除驱动器号?
使用 Visual Studio,我们总是加载并构建对单元的引用 (R:)。问题是,当有人编辑任何项目属性时,驱动器号将从程序集路径中删除,然后构建机器无法构建应用程序。
创建时项目文件如下所示:
<References>
<AssemblyReference
RelativePath="R:\ClientContext.dll"
AssemblyName="ClientContext, Version=8.3.0.0, PublicKeyToken=255e4d2a8e3ef422, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
编辑任何属性后:
<References>
<AssemblyReference
RelativePath="ClientContext.dll"
AssemblyName="ClientContext, Version=8.3.0.0, PublicKeyToken=255e4d2a8e3ef422, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
项目文件是 vcproj,不确定其他格式是否也会发生这种情况。
提前感谢伙伴们。
using visual studio we always load and build references to a unit (R:). The problem is that when someone edits any project properties the drive letter is removed from the assembly path and then the build machine can not build the application.
The project file looks like this when created:
<References>
<AssemblyReference
RelativePath="R:\ClientContext.dll"
AssemblyName="ClientContext, Version=8.3.0.0, PublicKeyToken=255e4d2a8e3ef422, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
And after editing any property:
<References>
<AssemblyReference
RelativePath="ClientContext.dll"
AssemblyName="ClientContext, Version=8.3.0.0, PublicKeyToken=255e4d2a8e3ef422, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
The project files are vcproj, notsure if this happens in other formats too.
Thanks in advance mates.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如其他人所说,根本问题是 IDE 希望有相对路径用于引用。这使得在具有不同机器设置的多个开发人员之间共享项目/解决方案变得更加容易。
编辑
正如 Hans 指出的,这个问题是关于 C++ 的,它不支持项目文件中的 HintPath 概念。以防 C#、VB.Net 或 F# 用户偶然发现该问题。
解决此问题的一种方法是使用参考上的 HintPath 子节点。这为 IDE 提供了在解析相对路径时查看何处的提示。
As other people have stated the root issue is that the IDE wants to have relative paths for references. This makes it much easier to share a project / solution between multiple develelopers who can have very different machine setups.
EDIT
As Hans pointed out this question is about C++ which doesn't support the notion of HintPath in the project file. Leaving up in case a C#, VB.Net or F# user stumbles across the question
One way to to work around this is to use the HintPath subnode on Reference. This gives the IDE a hint at where to look when resolving the relative path.
此页面可能会给您一些见解,特别重要的是有关“RelativePath”设置的注释:“相对路径 - 显示从项目目录到引用的程序集的相对路径。”
http://msdn.microsoft.com/en-us/library/47w1hdab.aspx
问题是它总是会重置它以相对于项目。
This page may give you some insight, particularly important is the comment about the "RelativePath" setting: "Relative Path - Displays the relative path from the project directory to the referenced assembly."
http://msdn.microsoft.com/en-us/library/47w1hdab.aspx
The issue is that it is always going to reset it to be relative to the project.
IDE 确实喜欢相对路径,因为绝对路径非常脆弱。当 R: 驱动器未正确映射时,您的构建也会中断。但它是可以修复的:项目+属性、公共属性、框架和引用。将 R:\ 路径添加到“其他参考搜索路径”列表中。
The IDE really likes relative paths because absolute ones are so brittle. Your build will also break when the R: drive isn't mapped properly. But it is fixable: Project + Properties, Common Properties, Framework and References. Add the R:\ path to the "Additional reference search paths" list.