如何复制本地工作的? log4net.dll没有被复制到MYPROJECT输出目录目录、工作、dll、log4net

2023-09-02 21:27:45 作者:装逼一顿锤@

我想知道什么复制本地=真正的引用究竟。是否连同其所有相关复制引用的组件的输出目录?

I am wondering what copy-local=true for references exactly does. Does it copy the referenced assembly along with all of its dependencies to the output directory?

我的场景是以下内容: 我有利用log4net的自定义日志包装。我建立MyLogWrapper.dll的释放组件与log4net.dll基准设置复制本地真实的。引用MyLogWrapper.dll从MyProject的与复制本地设置为true,应导致log4net.dll被复制以及对不对?我只是引用MyLogWrapper.dll,没有它在MyProject的依赖。 log4net.dll没有被复制到MYPROJECT输出目录,但MyLogWrapper的所有其他相关性。可能是什么问题?

My scenario is the following: I have a custom log wrapper that utilizes log4net. I build a release assembly of MyLogWrapper.dll with log4net.dll reference set to copy-local true. Referencing MyLogWrapper.dll from MyProject with copy local set to true should result in log4net.dll being copied as well right? I am only referencing MyLogWrapper.dll and none of its dependencies in MyProject. log4net.dll is not being copied to MyProject output directory but all other dependencies of MyLogWrapper are. What could be the problem?

我已经取得了一些更多的实验,它看来,如果我从GAC删除组件​​(log4net.dll),它开始变得本地复制。任何人都可以证实,这是什么问题?

I have made some more experiments and it seems that if I remove the assembly (log4net.dll) from GAC it starts to get copied locally. Can anyone confirm that this is the problem?

推荐答案

不幸的是,看来根据从 MSDN文档如预期已经装配在GAC中CopyLocal功能不起作用。

Unfortunately it appears that according to the following statement taken from the MSDN documentation the CopyLocal functionality does not work as expected for assemblies already in the GAC.

如果部署包含一个引用,该被登记在GAC定制组件的应用程序,该组件将不会被部署到应用程序,而不管CopyLocal设置。在Visual Studio中的previous版本,可以在基准设置CopyLocal属性,以确保大会部署。现在,你必须手动将程序集添加到 Bin文件夹。这使得所有自定义code下的监督,减少发布自定义code与不熟悉的风险。

If you deploy an application that contains a reference to a custom component that is registered in the GAC, the component will not be deployed with the application, regardless of the CopyLocal setting. In previous versions of Visual Studio, you could set the CopyLocal property on a reference to ensure that the assembly was deployed. Now, you must manually add the assembly to the Bin folder. This puts all custom code under scrutiny, reducing the risk of publishing custom code with which you are not familiar.

更多信息可以在下面的网页,其中介绍了有关项目引用是如何工作的细节中找到。

More information can be found at the following page which explains details about how project references work.

MSDN:项目参考