在一个解决方案中从多个项目创建一个 NuGet 包 [英] Creating one NuGet package from multiple projects in one solution

查看:16
本文介绍了在一个解决方案中从多个项目创建一个 NuGet 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个解决方案,其中包含 4 个类库项目(ABCD).AB 可以被视为解决方案中的顶级项目.AB 都引用 C,而 D 独立.

I have a solution that I'm working on that contains 4 class library projects (A, B, C, D). A and B could be considered the top level projects in the solution. Both A and B reference C, and D stands alone.

这四个项目代表了我制作的一组处理自动化工作流程的服务.它们都密切相关,并且只会在一个位置(服务管理器)使用,所以我不想将它们分成不同的解决方案.

These four projects represent a group of services that I have made that handle an automated workflow. They are all closely related, and will only be used in one location (the service manager) so I don't want to split them into different solutions.

我的问题是我想创建一个包含所有 4 个库的单个 NuGet 包,而不必全部构建它们并手动收集它们的 DLL.我知道我可以通过让 AB 引用其余项目在技术上实现这一点,但这不是真正的关系,我认为应该避免这种关系.

My problem is that I want to create a single NuGet package that will contain all 4 libraries, without having to build them all and gather up their DLLs manually. I know that I could technically achieve this by having either A or B reference the remaining projects, but that's not a true relationship and I feel it should be avoided.

我在这个问题上做了很多搜索,除了手动收集 DLL 并自己构建包之外,我找不到解决方案.有没有办法使用 NuGet 的特性/能力实现我想要的结果?

I've done a lot of searching on this problem and I can't find a solution other than manually collecting the DLLs and building the package myself. Is there a way to achieve the result that I want using NuGet's features/abilities?

注意:如果标签不明确,我目前正在使用带有 TeamCity 构建服务器的 VS2010.如果它是相关的,我还通过 Stash 服务器使用 Git.

NOTE: In case the tags don't make it clear I'm currently using VS2010 with a TeamCity build server. In case it's relevant I'm also using Git through a Stash server.

编辑:我刚刚意识到这可能很重要,值得一提.这些项目确实引用了我需要标记为依赖项的其他 NuGet 包.

EDIT: I just realized this might be important enough to mention. These projects do reference other NuGet packages that I will need to mark as dependencies.

推荐答案

您必须定义自己的 nuspec 清单.您可以在 files 部分列出包含的程序集:

You have to define your own nuspec manifest. You can list containing assemblies in files section:

<file src="AinReleaseA.dll" target="lib
et40" />
<file src="BinReleaseB.dll" target="lib
et40" />
...

有关详细信息,请阅读 NuSpec 参考.

For more details read NuSpec reference.

然后在 NuPack 构建步骤而不是 proj 中引用该 nuspec 文件.

Then reference that nuspec file in NuPack build step instead of proj.

这篇关于在一个解决方案中从多个项目创建一个 NuGet 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆