Nuget - 用多个项目打包解决方案(针对多个框架) [英] Nuget - packing a solution with multiple projects (targeting multiple frameworks)

查看:63
本文介绍了Nuget - 用多个项目打包解决方案(针对多个框架)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下解决方案,其中包含多个版本的相同代码,每个版本都针对不同的框架,我想从中生成一个 nuget 包.

Say I have the following solution with multiple versions of the same code each targeting a different framework and I would like to generate a nuget package from it.

SharedLib.sln
  SharedLib.Net35.csproj
    packages.config
  SharedLib.Net40.csproj
    packages.config
  SharedLib.Phone.csproj
    packages.config
  SharedLib.SL4.csproj
    packages.config

预期的 nupkg 具有以下结构

The expected nupkg has the following structure

SharedLib.1.0.nupkg
  lib/net35/SharedLib.dll
  lib/net40/SharedLib.dll
  lib/sl4-wp/SharedLib.dll
  lib/sl4/SharedLib.dll

nuget.exe pack SharedLib.SL4.csproj 会自动判断目标框架是 SilverLight4 并将二进制文件放在 lib/sl4

nuget.exe pack SharedLib.SL4.csproj will automatically determine that the target framework is SilverLight4 and place the binaries in lib/sl4

我知道我可以添加带有 部分的 SharedLib.SL4.nuspec 文件以包含来自其他项目的二进制文件,但有没有办法让nuget 会自动将组合的解决方案输出放入正确的结构中(并且还会从所有项目中检测 packages.config 中的依赖项?

I know I can add a SharedLib.SL4.nuspec file with a <file> section to include binaries from the other projects but is there a way to make nuget automatically place the combined solution output into the proper structure (and also detect dependencies in packages.config from all projects?

推荐答案

不,目前没有办法做到这一点,只能编写一个自定义构建脚本,将文件放在正确的位置,然后在它们上运行 NuGet 包,或采用您描述的 .nuspec 方法.

No, there's currently no way to do this other than to write a custom build script that puts the files in the right place and then runs NuGet pack on them, or to take the .nuspec approach you described.

这是我们想要的功能,但还没有想到一个好的方法.然而,你的帖子只是给了我一个想法.

This is a feature we'd like to have, but haven't thought of a good way to do it. However, your post just gave me an idea.

今天,您可以将 nuget pack 指向 .csproj 文件.

Today, you can point nuget pack at a .csproj file.

我们可以考虑一种允许您将其指向 .sln 文件的方法,如果项目名称遵循某种约定,我们会将所有项目打包到一个包中.

We could consider an approach that allowed you to point it at a .sln file and if the project names follow some convention, we'd package all the projects into a single package.

如果您确实需要此功能,请考虑在 NuGet 问题跟踪器中记录问题.http://nuget.codeplex.com/workitem/list/basic

If you really want this feature, consider logging an issue in the NuGet issue tracker. http://nuget.codeplex.com/workitem/list/basic

这篇关于Nuget - 用多个项目打包解决方案(针对多个框架)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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