NuGet Pack - 针对 nuspec 或 csproj 打包的不同问题 [英] NuGet Pack - Different Problems Packing Against nuspec or csproj

查看:52
本文介绍了NuGet Pack - 针对 nuspec 或 csproj 打包的不同问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遇到了一些 catch-22.我正在使用 NuGet 和 TeamCity.我试过用 nuspec 文件做 NuGet pack,我也试过用 csproj 文件.每个人都有自己的问题:

I've run into a bit of a catch-22 here. I'm using NuGet and TeamCity. I've tried doing NuGet pack with the nuspec file, and I've also tried with the csproj file. Each has its own issue:

在 TeamCity 中,如果我将 nuspec 文件与 NuGet 包 一起使用,则 nuspec 文件中的 $version$ 令牌不会不更新.

In TeamCity, if I use the nuspec file with NuGet pack, the $version$ token, in the nuspec file, doesn't get updated.

如果我使用 csproj 文件将 TeamCity 更改为 NuGet 包$version$ 令牌会更新,但是生成的包只有其中的 EXE,以及所有依赖的程序集都丢失了.使用nuspec文件不会出现这个问题.

If I change TeamCity to NuGet pack using the csproj file, the $version$ token gets updated, however the resulting package only has the EXE in it, and all of the dependent assemblies are missing. This problem doesn't happen when using the nuspec file.

有没有办法两全其美?我希望更新 $version$ 令牌(在使用 csproj 时有效),我希望将依赖程序集包含在包中(其中使用 nuspec 时有效).

Is there a way to get the best of both worlds? I'd like the $version$ token to be updated (which works when using csproj), and I'd like the dependent assemblies to be included in the package (which works when using nuspec).

注意:我希望有一个解决方案,它不涉及创建 PowerShell 脚本,或者将代码/项目与构建技术 (TeamCity) 结合起来的东西.

Note: I'm hoping there is a solution that doesn't involve creating PowerShell scripts, or something that couples the code/project to the build technology (TeamCity).

推荐答案

我能够实现使用 $version$ 变量并将依赖程序集包含在包中.在 nuspec 文件中包含此内容有何作用:

I was able to achieve using the $version$ variable and having the dependent assemblies included in the package. What did it was including this in the nuspec file:

<files>
  <file src=".\*.*" target="content" />
</files>

所以基本上 bin\release 中的所有内容最终都在包的 content 文件夹中.我不确定内容文件夹是否是正确的位置,但至少它在那里.如果需要,我可以稍后更改目标.

So basically everything in bin\release ends up in the content folder in the package. I'm not sure if the content folder is the right spot, but at least it's there. I can change the target later, if needed.

总结:
- TeamCity 针对 csproj 文件构建
- nuspec 文件有 $version$,它会更新
- nuspec 文件指定要包含的文件(见上文)

Summary:
- TeamCity builds against the csproj file
- The nuspec file has $version$, and it gets updated
- The nuspec file specifies the files to include (see above)

这篇关于NuGet Pack - 针对 nuspec 或 csproj 打包的不同问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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