it would also seem that it is important to distinguish between file dependencies, where the dependency refers to the dll assembly file and project-dependent dependencies (i.e. what I ask for), where the dependency refers to the project and implicitly displays the file of this project.
Not really, no.
MSBuild does not care if the link refers to another project in the solution or to the DLL.
If ProjectA depends on ProjectB to build ProjectA ProjectB should already be built (and updated), MSBuild will then pull out its DLL (and not its C # code) and link it to ProjectA .
Adding a project link instead of a DLL is “syntactic sugar” for your convenience: in this way, MSBuild knows that it must choose the output of the project it refers to, no matter what the result.
Otherwise, you will have to manually create the dependency first, find its DLL and associate it with the project, repeating the process when you switch assembly configuration, move or rename things. Not very practical.
Will the other two DLLs be copied to the output directory?
If any element from the dependency is used directly from the project referenced by the assembly, this link will be copied.
An example is this solution layout:
- Mysolution
- MySolution.ConsoleApplication
- MySolution.FirstDependency
- MySolution.SecondDependency
- MySolution.ThirdDependency
- MySolution.FourthDependency
With this dependency chain:
- MySolution.ConsoleApplication
- MySolution.FirstDependency
- MySolution.SecondDependency
- MySolution.ThirdDependency
- MySolution.FourthDependency
If you create this solution, you will notice that in the output directory MySolution.ConsoleApplication will be DLLs for MySolution.FirstDependency , MySolution.SecondDependency and MySolution.ThirdDependency , but there is no DLL for MySolution.FourthDependency .
Why is that? When MSBuild creates MySolution.SecondDependency , he notices that there is a dependency declared in MySolution.FourthDependency , but since it cannot find any use of any element from MySolution.FourthDependency in the MySolution.SecondDependency code, he decides to do some “optimization” and omits MySolution.FourthDependency MySolution.FourthDependency assembly.
The same problem bit me in the past when I added “deep dependency” through NuGet AutoMapper: adding AutoMapper adds two assembly links, AutoMapper and AutoMapper.Net4 , where the second assembly is loaded first by reflecting when it needs to perform a certain action on new collection objects provided by the .NET Framework 4. Since the second assembly is loaded via reflection, MSBuild considers it unused and does not attempt to copy it.
So yes, they will be copied as long as you use them directly and not through reflection.
Is it documented anywhere?
This behavior seems to be a “feature” of MSBuild, I was able to find a blog post from some people from Microsoft when I ran into this problem, but I cannot find it again at the moment.