How to inherit referenced assemblies in NuGet package

旧城冷巷雨未停 提交于 2019-12-24 06:49:41

问题


Simple question. I have a NuGet package project. This project references other class library projects (they are not NuGet Packages). I would like my NuGet package to load its references DLL's into the project installing the package. Is this possible, or do all my referenced class libraries need to be NuGet packages in order to specify them as dependencies?

TIA


回答1:


You can add your referenced dlls as files to nuspec and can set immediately source path file and target path file inside a nuget package. Next you should add references to this files in nuspec. It looks like this (I removed other metadatas):

.nuspec

<?xml version="1.0" encoding="utf-8"?>
<package>
  <metadata>
    ...
    <references>
      <reference file="First.dll" />
      <reference file="Second.dll" />
    </references>
  </metadata>
  <files>
    <file src="SomePath\First.dll" target="lib\First.dll" />
    <file src="SomePath\Second.dll" target="lib\Second.dll" />
  </files>
</package>



回答2:


When performing a nuget pack command, you can specify the option IncludeReferencedProjects.

From the docs:

Indicates that the built package should include referenced projects either as dependencies or as part of the package. If a referenced project has a corresponding .nuspec file that has the same name as the project, then that referenced project is added as a dependency. Otherwise, the referenced project is added as part of the package.



来源:https://stackoverflow.com/questions/45112285/how-to-inherit-referenced-assemblies-in-nuget-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!