Azure Pipelines .net 核心 3.1 库以及对其他库的引用如何创建一个 nuget 包

Azure Pipelines .net core 3.1 library with references to other libraries how to create one nuget package

我有 Visual Studio 解决方案,其中包含 10 个 .net core 3.1 库项目(我们称它们为 CORE)。其中之一是一个主要项目。它引用了其他项目。

我想要一个 nuget 包(存储在 azure feed 中),我可以在我的其他解决方案中使用它,因为我不会在每次需要 CORE 功能时都添加所有 dll。我需要定义 Azure Pipeline 来完成这项工作。如何定义生成一个包含所有其他引用 (dll) 的包的管道?

构建 NuGet 包时,可以提供 -IncludeReferencedProjects 切换到 nuget pack 命令,引用的项目将作为包的一部分添加:

nuget pack MyProject.csproj -IncludeReferencedProjects

请注意,根据 the docs

If a referenced project includes a .nuspec file of its own, then NuGet adds that referenced project as a dependency instead. You need to package and publish that project separately.

我建议您熟悉一下 this article。有更多选项可以精细地控制包的内容。那里引用的原始 nuget 命令很容易映射到适当的 CI 任务。