简体   繁体   中英

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. All of those references have Copy Local set to '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. (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. It invokes ProjA code which should do it's thing, using the referenced plugin assemblies.

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. So Ninject doesn't load them, and the thing fails.

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? 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. 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; 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. 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!

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).

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. 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. And run from there. Don't just put your trust in VS and walk around like a blind mice.

You may also consider using the GAC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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