R – Visual studio recursive Copy local


Duplicate – this exact question was asked here – the only solution seems to be post build event.

In Visual studio 2008, I have the following projects:

  • A – references B

  • B – references Lib.dll

When B is built, Lib.dll appears in B/bin/Debug. (this is ok)

When A is built, B.dll appears in A/bin/Debug, but Lib.dll does NOT appear in A/bin/Debug.

Wouldn't it be logical behavior to copy also all B's dependencies to output path of A, since B will need these assemblies at run-time?

All references have copylocal = true.

(Now I have to reference all B's dependencies from A by hand, is that correct? I could also use a custom build step I guess. Anyway, does this behavior have any advantages/sense?)

Best Solution

This only works if the assembly is actually referenced by the .dll. i.e. If you have LibInterface.dll and LibImplementation.dll - and your code in A only references the classes in LibInterface.dll, there is no way to get LibImplentation.dll into the output for B (cleanly).

This also applies for any arbitary files - i.e. if you have Randon.myFile that is related to project A, this would be the desired procedure: 1. Add as copy local, or build event to project A (so turns up in output for project A) 2. In Project B, set "copy local" on project A ref. 3. You should then get everything in the output of project A in project B (including your file) - but you don't.

There could be some other option - "Copy Local - all" or something. This would help VS support IOC techniques, and clean abstractions.