0

Hereis the situation:

I have a folder that contains library DLLs, which are not built as part of my solution - lets say it is .\libs. I add references to these DLLs. I then build. Everything is fine.

If I then delete the libs folder and rebuild my solution, the compilation still succeeds! Weird - I would have expected compilation errors since the library dlls are not there!

But looking at the reference properties in Visual studio, I see that the reference path has been changed from .\libs\foo.dll to myproject\bin\Debug\foo.dll. So it is picking up the referenced DLL from its old build output.

If I open myproject.csproj in a text editor, I see that the HintPath of the reference is still .\libs\foo.dll. If I re-create the libs folder, visual studio still uses myproject\bin\Debug\foo.dll (it does not revert to the actual DLL I want!)

Is this expected behaviour? Is there a way to stop this behaviour because it is causing me problems - especially when I want to rebuild myproject with different versions of the libs: half the time I find that I am using a different version than what I wanted.

Chris Fewtrell
  • 7,555
  • 8
  • 45
  • 63
  • possible duplicate of [HintPath vs ReferencePath in Visual Studio](http://stackoverflow.com/questions/1882038/hintpath-vs-referencepath-in-visual-studio) – Grant Thomas Feb 03 '12 at 10:15
  • If it hurts then don't do it. Starting with copying the DLLs into /libs, reference them from their original build location instead. If you have to copy for some reason then check them into source control. If they change too frequently to make that practical then add the projects that created them to your solution. – Hans Passant Feb 03 '12 at 13:09

1 Answers1

1

This is not magic. Your DLL's Copy Local Property is probably set to true, that's all.
Setting it to false will get you the desired behaviour.

Mehdi LAMRANI
  • 11,289
  • 14
  • 88
  • 130