[英]How to inherit referenced assemblies in NuGet package
Simple question. 简单的问题。 I have a NuGet package project. 我有一个NuGet包项目。 This project references other class library projects (they are not NuGet Packages). 该项目引用其他类库项目(它们不是NuGet包)。 I would like my NuGet package to load its references DLL's into the project installing the package. 我希望我的NuGet包将其引用DLL加载到安装包的项目中。 Is this possible, or do all my referenced class libraries need to be NuGet packages in order to specify them as dependencies? 这是可能的,还是我所有引用的类库都需要是NuGet包才能将它们指定为依赖项?
TIA TIA
When performing a nuget pack
command, you can specify the option IncludeReferencedProjects . 执行nuget pack
命令时,可以指定选项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. 如果引用的项目具有与项目具有相同名称的相应.nuspec文件,则该引用的项目将作为依赖项添加。 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. 您可以将引用的dll作为文件添加到nuspec,并可以在nuget包中立即设置源路径文件和目标路径文件。 Next you should add references to this files in nuspec. 接下来,您应该在nuspec中添加对此文件的引用。 It looks like this (I removed other metadatas): 它看起来像这样(我删除了其他metadatas):
.nuspec .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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.