Rules of referenced assemblies copying

后端 未结 4 1629
南笙
南笙 2021-02-19 02:32

Which rules does VS (msbuild?) follow during solution build? In which cases it will copy indirectly referenced asemblies to output folder and in which not?

4条回答
  •  难免孤独
    2021-02-19 03:10

    My experience is that it copies all directly referenced assemblies, recursively - that is, anything directly referenced in your code, and anything that these reference too.

    Anything that is not referenced at compile time in your code will not be referenced. So references that only resolved at run time will not be copied. This is because, even though you may know exactly what it references, the copmpiler doesn't. Whether reflection or using the activator to reference it ( as in the two answers already given ) because at compile time, the actual type of the objects cannot be determined.

    The references in the project indicate where code references should be resolved to, but that is all - I think the evidence is that they wil not be copied - it is all based on the compile time coded references.

    This is one reason why some of the injection techniques can work, before the resolution of the reference need not be done at the point of compilation or even deployment.

提交回复
热议问题