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

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

问题描述

我正在使用的解决方案包含4个类库项目( A B C D ). A B 可以视为解决方案中的顶级项目. A B 均引用 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.我知道我可以通过 A B 引用其余项目来实现此目的,但这不是真正的关系,我认为应该避免.

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?

注意:如果标签不清楚,我当前将VS2010与TeamCity构建服务器一起使用.如果有必要的话,我也通过存储服务器使用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="A\bin\Release\A.dll" target="lib\net40" />
<file src="B\bin\Release\B.dll" target="lib\net40" />
...

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

For more details read NuSpec reference.

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

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

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

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