Chris Fewtrell
Chris Fewtrell

Reputation: 7725

Project's referenced DLL's path changes "by magic" when DLL is deleted

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.

Upvotes: 0

Views: 1085

Answers (1)

Mehdi LAMRANI
Mehdi LAMRANI

Reputation: 11597

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.

Upvotes: 1

Related Questions