简体   繁体   中英

How to inherit referenced assemblies in NuGet package

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

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.

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>

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