简体   繁体   English

参考另一个项目,其中带有“复制本地”

[英]Reference another project with Copy Local on it's reference

I have a project "ProjA" which wraps up references to several other projects and some 'plugin' assemblies. 我有一个项目“ ProjA”,其中包含对其他几个项目和一些“插件”程序集的引用。 All of those references have Copy Local set to 'True'. 所有这些引用的“本地复制”均设置为“ True”。 Note that the code in the plugin assemblies (which are project references) is not referred to in "ProjA" directly, but is loaded and located through DI/Ninject. 请注意,插件程序集中的代码(它们是项目引用)没有直接在“ ProjA”中引用,而是通过DI / Ninject加载和定位。 (So I'm using these project references as a way of getting the plugin assemblies into the output folder, see below for why) (因此,我将这些项目引用用作将插件程序集放入输出文件夹的一种方法,请参阅下面的原因)

I also have project "ProjB", which references ProjA. 我也有引用ProjA的项目“ ProjB”。 It invokes ProjA code which should do it's thing, using the referenced plugin assemblies. 它使用引用的插件程序集调用应做的ProjA代码。

The problem is, it doesn't work. 问题是,它不起作用。 The plugin assemblies are not copied down from the ProjA output folder (which they are 'copied local'-into) into the ProjB output folder. 插件程序集不会从ProjA输出文件夹(已“本地复制”)复制到ProjB输出文件夹中。 So Ninject doesn't load them, and the thing fails. 因此Ninject不会加载它们,并且事情失败了。

So my two questions: 所以我有两个问题:

  • If I have dictated to VS/msbuild that ProjA refers to projects P1, P2, P3, P4, and set copy local to true - why then would it assume only the main output assembly is required to make ProjA work? 如果我对VS / msbuild指示ProjA引用项目P1,P2,P3,P4,并将本地副本设置为true,那么为什么要假设只需要主输出程序集就可以使ProjA工作? Can I make it think any differently? 我可以换个角度思考吗?
  • I'm guessing that adding a Copy Local reference to the plugin assemblies as a way of having VS recognise a build dependency between the plugins and the project using them (currently a fixed set of plugins, hence this route) - is not ideal. 我猜想,向插件程序集添加“复制本地”引用是让VS识别插件和使用它们的项目(当前为一组固定的插件,因此这条路线)之间的构建依赖关系的一种方式-不理想。 I then think that adding the plugin assemblies as 'Content' to the project would work, but then I have two issues: 1) TFS source control; 然后,我认为将插件程序集作为“内容”添加到项目中是可行的,但是然后我遇到两个问题:1)TFS源代码控制; the plugin projects need a writable target to build to, presumably - content files would be 'checked in' and 2) some of the plugins have Content of their own: with references I don't need to worry about missing something. 插件项目需要一个可写的目标来构建,大概是-内容文件将被“检入”,并且2)一些插件具有自己的内容:有了引用,我不必担心丢失某些东西。 Going the Content route I need to refer to another project's build output folder, include all of it's content, but not the PDBs.. seems even more hacky! 走内容路线我需要引用另一个项目的build输出文件夹,包括所有内容,但不包括PDB。

I have also considered and played with post-build steps for either the plugin projects (not ideal: I am pulling them into this new solution from another, if I add post-build steps it will likely screw up the other solution) or the project which depends on them (which is OK, but an XCopy with relative paths, and having to manually set up Project Dependencies.. seems more hacky again). 我还考虑了插件项目的构建后步骤(并不理想:我将它们从另一个项目中拉到这个新解决方案中,如果我添加了构建后步骤,则很可能会破坏其他解决方案)或项目这取决于它们(可以,但是带有相对路径的XCopy,并且不得不手动设置项目依赖项。似乎又变得更加棘手了)。

Is there something I'm missing, any ideas at all? 有什么我想念的东西吗? If Copy Local chained across project references it would fit perfectly.. 如果跨项目引用链接“复制本地”,则将非常适合。

似乎无法使用Visual Studio或msbuild。

Copy local = true is the source of all VS evils. 复制local = true是所有VS弊端的根源。 Well, most at least. 好吧,至少是这样。

I'd go with just saying - don't use it. 我只想说-不要使用它。 Have one nice outputdir, like T:\\Bin, and copy everything you need using post build scripts to that dir. 有一个不错的outputdir,例如T:\\ Bin,然后使用构建后脚本将所需的所有内容复制到该目录。 And run from there. 然后从那里跑。 Don't just put your trust in VS and walk around like a blind mice. 不要只是相信VS,像瞎老鼠一样走来走去。

You may also consider using the GAC. 您也可以考虑使用GAC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM