6

I manually edited in a reference (Reference not ProjectReference) in my csproj file, and after reviewing the code, I can see that the hintpath is wrong:

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

The right path would be ..\..\..\..\..\Build\UnitTests\Company.Core.Data.Web.UnitTests.dll.

However, I notice that a clean build of my project works fine. Does this matter? Is this something I need to fix?

Elliott Beach
  • 10,459
  • 9
  • 28
  • 41
  • Why are you referencing the build output of a different project as a `` instead of a project reference in the first place? – Martin Ullrich Apr 10 '19 at 11:22
  • Because I did not design our (very large) teams' build system, using References is more of a requirement I must satisfy than a decision that I am able to make. I believe the reason is related to https://stackoverflow.com/questions/3047733/project-reference-vs-dll-reference-which-is-better#comment14233307_3048041 – Elliott Beach Apr 10 '19 at 13:01

1 Answers1

5

As described in https://stackoverflow.com/a/2733113/5749914, Visual Studio will search a number of locations for the DLL, and the fact that a clean build is working with a incorrect hint path indicates the hint path is not needed.

In this case, the $(outDir) was being searched: in my project, the outputPath tag was

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

which was the same directory my project was being built to.

So, if the referenced DLL is in the same build directory that the project is being built to, there is no need for a hintpath.

Elliott Beach
  • 10,459
  • 9
  • 28
  • 41
  • For example I have next ` ..\..\..\..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll ` Should version of reference be the same as in hint path or it doesn't matter? – demo Sep 29 '20 at 15:31