msbuild不复制引用的程序集 [英] msbuild not copying referenced assembly

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

问题描述

我有一个包含两个项目的解决方案: -projectA具有对ServiceStack ormlite的nuget引用 -projectB引用了projectA

I have a solution that contains two projects: - projectA has a nuget reference to ServiceStack ormlite - projectB has a reference to projectA

构建解决方案时,projectA的输出目录包含所有来自nuget程序包的程序集(4个程序集),而projectB仅复制其中的2个程序集.显然,当我启动它时,我得到一个FileNotFoundException. 我已经尝试添加private=true标志

When I build the solution the outdir for projectA contains all the assembly coming from nuget packages (4 assemblies), whereas the projectB only copies 2 of them. Obviously when I start it I get an FileNotFoundException. I have already tried with no success to add private=true flag

我已经看到过很多关于此问题的参考,现在它对这里发生的事情感到非常困惑(似乎msbuild无法以我认为唯一知道的方式处理参考:().

I have seen many references to this problem and it gets very confused now about what is going on here (it seems that msbuild does not handle reference the way I think is the only thing I know:().

任何想法如何建立一个可靠的流程来构建我的解决方案?

Any idea what could be done to have a reliable process to build my solution ?

推荐答案

内部版本只会将projectA实际使用的程序集复制到projectB的输出文件夹中,并且会在projectA的输出程序集中得到引用,而与projectA引用的程序集无关.

The build will only copy to projectB's output folder the assemblies that are actually used by projectA and result in references in projectA's output assembly, regardless of which assemblies projectA references.

您可以使用Reflector或ildasm打开projectA的程序集,并查看这4个程序集中只有2个实际被使用和引用.

You can open projectA's assembly with Reflector or ildasm and see that of those 4 assemblies only 2 are actually used and referenced.

如果程序集在运行时需要在程序B处存在,请将对NuGet包的引用也添加到projectB,或确保将它们复制.这篇文章显示了通用解决方案,但是我还没有尝试过.

If the assemblies need to be there at runtime for projectB, add a reference to the NuGet package to projectB as well, or make sure they are copied. This post shows a general-purpose solution, but I haven't tried it.

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

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