Wrt. the proposed dupe: Since this here queston suggests the opposite of the linked question, I'd rather like to think it is not a dupe.
First, I did read What is the best practice for “Copy Local” and with project references? (also this) and I'll have to try this out anyway, but getting general feedback on this seems necessary as the docs on this stuff are horrible and I'm only on VS2010 and maybe they changed something in newer versions that'll be nice to know.
Second, I'm only interested in project references for this question as I've read that assemblies from the GAC are handled differently and the GAC is irrelevant for my problem.
Third, after reading the suggested dupe, but more so the nice answer here by @Albireo, it would also appear that it is important to differentiate file dependencies, where the dependency references a dll assembly file and project dependencies (i.e. what I'm asking about), where the dependency references a project and implicitly the output file of that project.
Anyway, here's the situation, somewhat peculiar I think, but still:
- 2 C# executable projects
- n C# dll assembly projects
- The 2 executables have different output directories as they will be deployed separately and that way they're also separate on the developer machine
- The 2 executables have dependencies on some of the DLL assemblies (which may depend on each other)
- There are three output directories:
/x1
for executable 1 project/x2
for executable 2 project/lib
for all the dll assemblies
The DLL assemblies all have Copy Local
set to false
for their project references, as they all build to the same output directory.
The 2 executable projects have set Copy Local
to true
for all the DLL assembly project references they reference directly, so that the DLLs will be copied into /x1
/x2
respectively.
The question now is wrt. to DLLs that are not directly referenced by an executable project, but only transitively through a referenced assembly: Will assemblies, that are only referenced transitively through another assembly, be copied into the output folder of the executable, when "Copy Local" is set to true on the first assembly?
Example:
x1.csproj
(e.g.Output =x1/one.exe
)- Reference:
dlA.csproj
( e.g. Output =lib/a.dll
) withCopy Local = *true*
- (no direct reference on b.dll)
- Reference:
dlA.csproj
( e.g. Output =lib/a.dll
)- Reference:
dlB.csproj
( e.g. Output =lib/b.dll
) withCopy Local = **false**
- (no direct reference on c.dll)
- Reference:
dlC.csproj
( e.g. Output =lib/c.dll
)- (no further relevant references)
Thus, we have a logical dependency of one.exe -> a.dll -> b.dll -> c.dll
, where only a.dll
with obviously be copied to the output directory of one.exe
. Will the other two dlls also be copied to the output directory? Is this documented somewhere?
And, yes, I tried it. And, yes, it seems to work, but I haven't poked it hard enough yet and anyway there maybe something more to it that I may have missed. (And also there's the question wrt. any official docs.)
ResolveAssemblyReference
Task documented. Maybe looking further into that can shed some light on this ... – Camarena