简体   繁体   English

如何在NuGet包中继承引用的程序集

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

<?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.

相关问题 2 个组件中引用的 Nuget package 不起作用 - Nuget package referenced in 2 assemblies does not work 如何从引用的NuGet程序包中正确选择程序集? - How do I properly choose assemblies from referenced NuGet packages? Fody NuGet 包如何在编译过程结束时合并程序集? - How does the Fody NuGet package merge assemblies at the end of the compile process? 更新软件包引用的nuget软件包 - Update nuget package referenced by package 在nuget包中包含引用的项目 - Include referenced project in nuget package 如何从引用的nuget包中加载Azure活动功能 - How to load azure activity function from a referenced nuget package 如何更喜欢Nuget程序集而不是SDK程序集? - How to prefer Nuget assemblies over SDK assemblies? Nuget命令行-从包中提取兼容程序集 - Nuget commandline - extracting compatible assemblies from package 如何解决在新导入的 Xamarin Forms Nuget 包上导入的多个程序集 - How to resolve Multiple assemblies being imported on a newly imported Nuget package for Xamarin Forms MonoGame安装的程序集与MonoGame.Binaries NuGet程序包中的程序集有何不同? - How are the assemblies installed by MonoGame different from those in the MonoGame.Binaries NuGet package?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM