DLL引用不复制到项目仓 [英] DLL reference not copying into project bin

查看:221
本文介绍了DLL引用不复制到项目仓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

项目A 引用 项目B 项目B 引用外部DDL(使用的NuGet恢复)。该DLL应被复制到 项目A 的bin文件夹(以及 项目B 的DLL):

Project A references Project B, and Project B references an external DDL (restored using NuGet). The DLL should get copied into Project A's bin folder (along with Project B's DLL):

在我的情况下,在运行时的项目A 后,我得到了以下异常抛出:

In my case, when running Project A, I get the following exception thrown:

无法加载文件或程序集PostSharp,版本= 3.2.18.0,
区域性=中性公钥= b13fd38b8f9c99d7'或其
依赖关系之一。该系统找不到指定的文件。

Could not load file or assembly 'PostSharp, Version=3.2.18.0, Culture=neutral, PublicKeyToken=b13fd38b8f9c99d7' or one of its dependencies. The system cannot find the file specified.

该DLL不被复制到 项目A 的纸盒。从 项目B 被复制跨就好了,这是什么是混淆了我。

The DLL is not being copied into Project A's bin. All other external references from Project B are being copied across just fine, which is what is confusing for me.

复制本地设置为true所涉及的所有引用。例如:

Copy Local is set to true for all references involved. Example:

我如何做到这一点?

请注意:使用Visual Studio 2013

Note: Using Visual Studio 2013.

推荐答案

该选项我发现是到:


  • 添加在项目A到PostSharp参考

  • 添加虚拟代码在项目b,这样编译器将检测正在使用的参考。

  • 添加生成事件迫使复制DLL。

我不喜欢任何上述解决方案。他们是在我看来,黑客和只会使在长远来看更难以维护的解决方案。

I don't like any of the above solutions. They are hacks in my opinion and will only make for a more unmaintainable solution in the long run.

我以一个常见的​​输出目录解决了这一问题。这似乎是许多人建议的解决方案。我也遇到过更快的构建时间。请参见这个岗位#1

I have fixed the problem by using a common output directory. This seems to be a recommended solution by many. I have also experienced much faster build times. See this Stackoverflow post.

这篇关于DLL引用不复制到项目仓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆