为具有多个项目的解决方案创建nuget包
我们目前正在构建包含多个项目的解决方案。为具有多个项目的解决方案创建nuget包
我们有这样的事情:
- Common
- Logging
- Logging.NLog
- Threading
所以Logging.NLog取决于日志,日志中常见...等。
当我们打包Logging.NLog时,我希望nuget发现Loggin和Common dependecies。
此刻,我创建了常见的一个包,然后在登录我安装包常见的有
install-package Common
但每当我做了修改,以常见的,我一定要更新包,并在创建通过我们的持续集成系统(Hudson),所以当我们开发时它非常烦人。
我想简单地有一个项目参考(添加引用 - >项目...)和nuget无论如何发现依赖关系。
有没有办法实现它?
有计划feature瞄准了这一确切的情况。
这是怎么回事显然将是这样的:
> nuget.exe pack proj.csproj -IncludeReferencedProjects
它显然已经implemented仅仅天前,但也有bugsstillbeingironedout。
的功能,因为它目前为,允许:
- (步行项目引用递归),包装几个项目的文物到一个单一的NuGet包
OR
- 创建nuget包对这些项目的引用如果引用的项目具有随附的.nuspec文件,则关联的包。
功能请求可以一直追溯到1.5,但它一直在滑动。最近,它收集了足够的质量(请求)以便在Nuget 2.3中发布。
发布计划钉住了2013年4月底的2.3版本,敬请期待。
(目前,最新的Nuget版本是2.2.1)。
这似乎在我的版本(2.5.40416.9020)中工作得很好,不需要在.nuspec文件(本例中为proj.nuspec)中的任何
我认为Charles意味着他希望NuGet自动将项目引用解析为包依赖关系,如果所引用的项目也用于构建NuGet包,对吧?
实施例:
- 日志记录被设置为产生一个NuGet包
- Logging.Nlog被设置为产生一个NuGet包
- Logging.Nlog具有项目引用日志记录。
- 生成的Logging.Nlog程序包应该依赖生成的Logging程序包。
这是我一直在寻找自己的东西,但遗憾的是我发现它目前不支持。其上有一个work item,计划用于NuGet 1.7,但是甚至没有关于如何处理这个问题的设计。
是的,你是对的!谢谢你提供的信息 –
目前没有办法完全按照您的要求进行操作,但以下内容将帮助您简化更新。
这听起来像你需要添加nuspec文件到你的解决方案。类似以下三个文件。注意后面两个的依赖关系。这些引用与[$ version $]中常见的dll版本相同。这意味着当您运行以下命令时,它会更新所有这三个,因为依赖项上的方括号需要特定版本的相关软件包。常见
在哈德森
PM>更新包,您将需要执行使用的NuGet包命令(see Nuget command reference)这些nuspec文件,包括所得封装在你的文物,并将其部署到本地的NuGet服务器。我会把它留给你。
您需要做的另一件事是确保您的所有程序集都获得相同版本的相同版本。再次,哈德森可以照顾这一点,或者你可以使用一个通用的AssemblyInfo文件。
Common.nuspec
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>$version$</version>
<authors>Charles Ouellet</authors>
<owners />
<iconUrl>http://domain/Content/images/LOGO_32x32.png</iconUrl>
<id>Common</id>
<title>Common</title>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>full description here</description>
</metadata>
<files>
<file src="..\Common\bin\Release\Common.dll" target="lib\net40" />
<file src="..\Common\bin\Release\Common.pdb" target="lib\net40" />
</files>
</package>
Logging.nuspec
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>$version$</version>
<authors>Charles Ouellet</authors>
<owners />
<iconUrl>http://domain/Content/images/LOGO_32x32.png</iconUrl>
<id>Logging</id>
<title>Logging</title>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>full description here</description>
<dependencies>
<dependency id="Common" version="[$version$]" />
</dependencies>
</metadata>
<files>
<file src="..\Logging\bin\Release\Logging.dll" target="lib\net40" />
<file src="..\Logging\bin\Release\Logging.pdb" target="lib\net40" />
</files>
</package>
Logging.NLog
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>$version$</version>
<authors>Charles Ouellet</authors>
<owners />
<iconUrl>http://domain/Content/images/LOGO_32x32.png</iconUrl>
<id>Logging.NLog</id>
<title>Logging.NLog</title>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>full description here</description>
<dependencies>
<dependency id="Logging" version="[$version$]" />
</dependencies>
</metadata>
<files>
<file src="..\Logging.NLog\bin\Release\Logging.NLog.dll" target="lib\net40" />
<file src="..\Logging.NLog\bin\Release\Logging.NLog.pdb" target="lib\net40" />
</files>
</package>
YES!这也许是我需要的。我现在会尝试,但是这样我可以有一个VS解决方案,说3个项目,每个项目都可以引用解决方案中的其他项目,但是当我打包它们时,它们都是与其他包相关的单独包。好吧,要去试试。thx – Raif
您的意思是说,当您为Logging构建一个NuGet包时,您希望它为Common包含一个依赖项,因为Common包含在通过NuGet记录中? –
[在一个解决方案中从多个项目创建一个NuGet包]可能的副本(https://stackoverflow.com/questions/15882770/creating-one-nuget-package-from-multiple-projects-in-one-solution) –