Nuget: specify dependency without references being added
I have a package (say, MyStuff.Data) that requires EntityFramework (and others) to work, but only internally. I don't want every project that uses MyStuff.Data to also reference EntityFramework (and all those others), but the dll always needs to be there.
Is there any way I can add EntityFramework as a dependency of MyStuff.Data (so that it picks up EntityFramework.dll in the packages folder), but without a reference being added to each project that consumes it?
No there is not. An option could be to embed the EntityFramework dll and ship it inside your own package, and explicitly state which references should be added in the target project during installation. You can specify this using the metadata element in the nuspec of you package. More information can be found in the docs here: http://docs.nuget.org/docs/reference/nuspec-reference#Specifying_Explicit_Assembly_References
Notice that embedding a specific version of a dependency is a limiting constraint on all your consumers, which means that you, as a package producer, will be driving which version of EF your consumers can and will be using... which is not a good situation to be in.
Preferably, you try to abstract out any non-controlled (EF) dependency and leave the real implementation choice to the consumer (or you provide a separate package containing the implementation, so your consumers can still opt-in and use yours).
链接地址: http://www.djcxy.com/p/10676.html下一篇: Nuget:指定不添加引用的依赖关系