Difference between project dependencies and .Net dlls in final assembly

Suppose I have two projects A and B. A depends on B. I can indicate this in two ways:

  • Include A and B in the same solution and specify B as the dependency of the project on A. This is displayed in project A msbuild as a "ProjectReference" node.
  • Include link to compiled dll B as a dependency for A. This appears in the msbuild project as a "Link" node

My question is: as soon as I build the assembly for A, is there any difference in the final output between the two methods.

I tried to create a couple of simple projects that model this relationship and tried the comparison, but different comparison tools tell me different things. In anticipation of writing something comparing these files by bytes, I was wondering if you knew that you knew about it. In particular, will there be any difference in the behavior of the inline assembly if I use the dll link instead of the project link.

+6
c #
source share
2 answers

If the sources of project B have not changed between the two assemblies of project A, there will be no difference in the behavior of the output of project A. However, if the sources of project B have changed, referring to it as a project from project A will lead to a rebuild of project B. This difference determines your choice of How to reference Project B from Project A:

  • if you have a source of both project B and project A, and they are closely related to each other, or if they are both under active development, and project B often breaks changes in its public interface, you want to refer to project B as a project. This would ensure that Project A always uses the most modern output of Project B in its assembly.

  • if project B is an external dependency that you do not develop yourself, or you don’t have sources, or if it is already submitted, and you cannot send a modified version using project A, you want to reference the finished project B, so that you develop and tested the same version of project B, which is likely to be on the computers of your users.

+5
source share

Adding as a reference to the project has the advantage that assembly "B" is automatically created if required.

After assembling assembly "A" there is no difference.

+3
source share

All Articles