How to install "Copy local dependencies" in C # projects [problem with CopyLocal]

I have an assembly called A.dll, which has a project link to an assembly called B.dll. The node referenced by B.dll has a binary link to C.dll.

A.dll → B.dll → C.dll

I set Copy A local in A.dll from B to true, and I set Copy Local to false in B.dll for C.dll.

Anyway, when I create A.dll, I end C.dll in the results folder. Why is the "Copy local" B.dll to C.dll value not taken into account?

thanks

+4
source share
2 answers

This is because msbuild was able to find c.dll. He knows nothing about the local copy settings for project B. He simply looks at the .assembly directives in the b.dll metadata and sees that c.dll is a dependency. And if he finds c.dll, he will copy it. If he cannot find him, nothing will happen, no complaints either.

The odd part and your solution is that c.dll is present in the same directory as b.dll. How did he get there? Just stop it from copying and it will not be copied to the assembly directory A. Otherwise, it is rather gloomy, as you expect it to ever start.

+4
source

This means that CopyLocal copies the referenced assembly and its dependencies to the output folder, unless the referenced assembly or dependency is in the GAC.

Since you installed CopyLocal in reference B , both B and its dependency C will be copied to output folder A , even if you did not install CopyLocal on reference C in project B

Note that if you create B , C not copied to folder B

If you want B be copied to output folder A , but don't want this to happen to C , one solution would be to put C in the GAC.

+3
source

Source: https://habr.com/ru/post/1335821/


All Articles