0

Our solution has a "Lib" folder, which contains a DLL ("A.dll") stored in source control.

My Project looks like the following (simplified):

Website
- References
-  * Reference to A.dll from Lib folder below *
- Content
- Lib
-   A.dll (Build Action: Content, Copy to Output: Do not copy)
-   B.dll (Build Action: Content, Copy to Output: Do not copy)
- Migrations
- Views

A has a reference to/uses B, but B is not included as a reference within the Website.

When I hit compile Visual studio puts B in the bin folder, how did it know to do this? Even if I leave B where it is, but don't let the Website project see it (not include it in the project), it's still put in the bin folder.

However if I put B in the Migrations folder, it is not copied to the bin folder. The Lib and Migrations folder have no special properties against them (that I can see).

How does this work, is it documented?

Lee
  • 1,591
  • 1
  • 14
  • 28
  • The metadata of a .NET assembly contains an entry for the dependent assemblies. Msbuild reads it to find out if they need to be copied as well. So it sees that B is a dependency for A. If it finds the file then it copies it. If not then it *silently* skips the copy. – Hans Passant Dec 17 '14 at 12:06
  • How does it know to look in the Lib folder? It just happened to be the location A was placed in, and not the place A was originally compiled to. – Lee Dec 17 '14 at 12:08
  • From the reference you added. The `` property of the A reference points to the Lib folder. – Hans Passant Dec 17 '14 at 12:09
  • That's how it found A, does it just use A's hintpath to find B? – Lee Dec 17 '14 at 12:09
  • 1
    It looks in the same directory where A was found. – Hans Passant Dec 17 '14 at 12:10
  • If you want to post that as an answer I'll accept it, otherwise I'll copy your answer later to get it out my unanswered list. Thanks for your help. – Lee Dec 17 '14 at 12:13
  • This goes wrong too often. I don't want to write an answer that says why programmers don't have the problem they have. – Hans Passant Dec 17 '14 at 12:27

1 Answers1

0

As per the comments, it was explained that the reason it is working in the instance is because it searched for B in the same location it found A.

As this helped my understanding, I've posted it as an answer in case it is of use to anyone else.

Thanks Hans for your help.

Lee
  • 1,591
  • 1
  • 14
  • 28