【问题标题】:Do I need to have a hintpath in my csproj file reference?我的 csproj 文件参考中是否需要有提示路径?
【发布时间】:2019-08-31 19:47:40
【问题描述】:

我在我的csproj文件中手动编辑了一个引用(Reference不是ProjectReference),查看代码后发现提示路径错误:

+    <Reference Include="Company.Core.Data.Web.UnitTests">
+      <HintPath>..\..\..\..\..\Code\Bin\Company.Core.Data.Web.UnitTests.dll</HintPath>
+      <Private>True</Private>
+    </Reference>

正确的路径是..\..\..\..\..\Build\UnitTests\Company.Core.Data.Web.UnitTests.dll

但是,我注意到我的项目的干净构建工作正常。这有关系吗?这是我需要解决的问题吗?

【问题讨论】:

  • 为什么你首先将不同项目的构建输出引用为&lt;Reference&gt; 而不是项目引用?
  • 因为我没有设计我们(非常大的)团队的构建系统,所以使用引用是我必须满足的要求,而不是我能够做出的决定。相信原因和stackoverflow.com/questions/3047733/…有关

标签: visual-studio csproj


【解决方案1】:

https://stackoverflow.com/a/2733113/5749914 中所述,Visual Studio 将在多个位置搜索 DLL,而干净的构建使用不正确的提示路径这一事实表明不需要提示路径。

在这种情况下,正在搜索 $(outDir):在我的项目中, outputPath 标记是

<OutputPath>..\..\..\..\..\Build\UnitTests\</OutputPath>.

我的项目正在构建到同一个目录。

因此,如果引用的 DLL 位于项目正在构建的相同的构建目录中,则不需要提示路径。

【讨论】:

  • 例如我有下一个&lt;Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"&gt; &lt;HintPath&gt;..\..\..\..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll&lt;/HintPath&gt; &lt;/Reference&gt; 引用的版本应该与提示路径中的相同还是无关紧要?
猜你喜欢
  • 1970-01-01
  • 2021-05-01
  • 1970-01-01
  • 2016-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-23
  • 2013-03-17
相关资源
最近更新 更多