Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

Why are you referencing the build output of a different project as a <Reference> instead of a project reference in the first place? – Martin Ullrich Apr 10, 2019 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 stackoverflow.com/questions/3047733/… – Elliott Beach Apr 10, 2019 at 13:01

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.

For example I have next <Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <HintPath>..\..\..\..\..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath> </Reference> Should version of reference be the same as in hint path or it doesn't matter? – demo Sep 29, 2020 at 15:31

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.