我的 csproj 文件引用中是否需要有提示路径?

War*_*zee 6 csproj visual-studio

我在 csproj 文件中手动编辑了引用(Referencenot ProjectReference),在检查代码后,我可以看到提示路径是错误的:

+    <Reference Include="Company.Core.Data.Web.UnitTests">
+      <HintPath>..\..\..\..\..\Code\Bin\Company.Core.Data.Web.UnitTests.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
Run Code Online (Sandbox Code Playgroud)

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

然而,我注意到我的项目的干净构建工作得很好。这有关系吗?这是我需要解决的问题吗?

War*_*zee 5

如/sf/answers/191317941/中所述,Visual Studio 将搜索 DLL 的多个位置,并且干净构建使用不正确的提示路径这一事实表明不需要提示路径。

在本例中,正在搜索 $(outDir):在我的项目中,outputPath 标记是

<OutputPath>..\..\..\..\..\Build\UnitTests\</OutputPath>.
Run Code Online (Sandbox Code Playgroud)

这与我的项目构建的目录相同。

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