简体   繁体   English

在Nuget包中添加对程序集的引用

[英]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.

相关问题 NuGet包无法为lib目录中的DLL添加对项目的引用 - NuGet Package fails to add reference to project for DLL inside lib directory 程序集引用未与自定义nuget包一起添加 - Assembly reference not being added with custom nuget package 无法添加对已安装 NuGet 包的引用? - Unable to add reference to installed NuGet package? Nuget软件包未安装,添加参考失败 - Nuget package not installing, failed to add reference 在nuget包中添加第三方COM参考 - Add third party COM reference in nuget package ILMerge - “不允许未解析的程序集引用”,RestSharp Nuget package 在包文件夹中 - ILMerge - "Unresolved assembly reference not allowed", RestSharp Nuget package in the packages folder 如何将Singleton类添加到NuGet的参考程序集中 - How can I add a Singleton class to a reference assembly for NuGet 私人TeamCity Nuget不添加程序集参考 - Private TeamCity Nuget doesn't add assembly reference NuGet Package 管理问题 - 定位程序集的清单定义与程序集引用不匹配 - NuGet Package Management problem - The located assembly's manifest definition does not match the assembly reference 避免添加 nuget 包引用以支持程序集引用的可能性,包括。 依赖? - Possibility to avoid adding nuget package reference in favor of assembly reference incl. dependencies?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM