.net - 复制本地如何工作? log4net.dll 没有被复制到 MyProject 输出目录

标签 .net build dependencies

我想知道引用的 copy-local=true 到底是做什么的。它是否将引用的程序集及其所有依赖项复制到输出目录?

我的情况如下: 我有一个使用 log4net 的自定义日志包装器。我构建了一个 MyLogWrapper.dll 的发布程序集,其中 log4net.dll 引用设置为 copy-local true。从 MyProject 引用 MyLogWrapper.dll 并将本地复制设置为 true 应该会导致 log4net.dll 也被复制,对吗?我只在 MyProject 中引用 MyLogWrapper.dll 而没有它的依赖项。 log4net.dll 没有被复制到 MyProject 输出目录,但 MyLogWrapper 的所有其他依赖项都是。可能是什么问题?

我做了更多的实验,似乎如果我从 GAC 中删除程序集 (log4net.dll),它就会开始在本地复制。谁能确认这是问题所在?

最佳答案

不幸的是,根据以下从 MSDN documentation对于 GAC 中已有的程序集,CopyLocal 功能无法按预期工作。

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.

更多信息可以在以下页面中找到,该页面解释了有关项目引用如何工作的详细信息。

MSDN: Project References

关于.net - 复制本地如何工作? log4net.dll 没有被复制到 MyProject 输出目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/320295/

相关文章:

xaml - XAML 构建的本地 TFS 到 VSTS 迁移

android - Android Studio 中的 Base64 依赖问题

c# - 短代码正则表达式

c# - 如何通过 OPENXML 解析存储过程中的 xml 序列化 List<int>?

c - 如何正确链接 KBuild Makefile 以在内核模块中构建子文件夹

javascript - 在 CKEditor 5 的自定义构建中导出 ClassicEditor

c# - 在 VS2015 社区中使用 ASP.NET 5 时的 "Cannot resolve symbol ' 系统 '"和其他命名空间

c# - 获取所有已实现接口(interface)的列表

java - 如何在编译时访问嵌套依赖项?

node.js - 错误 : Invalid version: "1.0" in node. js package.json 文件