[英]Add reference to assembly inside Nuget package
I'm writing a C# class library for net461 that is consuming a NuGet package. 我正在为net461写一个C#类库,它正在使用NuGet包。 The package adds two assembly references to my project as these are the ones you normally need. 该软件包将两个程序集引用添加到我的项目中,因为这些引用通常是您需要的。 But in this special case, I also need to reference a third assembly inside the package. 但是在这种特殊情况下,我还需要引用包装内的第三个组件。 I can easily do this by pointing to the folder beneath Packages folder, but that will give me a version-dependent hint path that will break next time the consumed package is updated. 我可以通过指向Packages文件夹下的文件夹轻松完成此操作,但这将为我提供一个与版本有关的提示路径,该路径将在下次更新使用的软件包时中断。
How can I avoid this scenario? 如何避免这种情况? I cannot seem to find any way in VS2017 to do a "deep" assembly reference into the referenced Nuget package... 我似乎无法在VS2017中找到任何方法对引用的Nuget包进行“深层”程序集引用...
I am also the author of the consumed package, so I could expose the third assembly as as well, but that would pollute the 99% other projects only needing the two first assembly references. 我还是消费包的作者,因此我也可以公开第三个程序集,但这会污染99%的仅需要两个第一个程序集引用的项目。
Thanks in advance Ulrik 在此先感谢Ulrik
Create another nuget package that references your existing nuget package as a dependency. 创建另一个引用您现有的nuget包作为依赖项的nuget包。 Then add the additional assembly reference in what is basically a wrapper package. 然后,在基本上是包装器的程序包中添加其他程序集引用。 Consume that instead. 取而代之。
Or 要么
Create a copy of the nuget package that includes the assembly reference and add a suffix to the package name. 创建包含程序集引用的nuget程序包的副本,并在程序包名称中添加后缀。 Only issue is you will have to publish two packages whenever you change it. 唯一的问题是,每次更改它都必须发布两个程序包。 Not sure if it will matter when you have projects using each in the same solution as the dlls should match. 不知道当您使用与dll应该匹配的相同解决方案中的每个项目时是否重要。
Or 要么
Just include the assembly as a reference and pollute the other projects. 仅将程序集作为参考,并污染其他项目。 I don't think it will hurt. 我不认为会痛。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.