使用 Nant 将 TeamCity 内部版本号添加到 AssemblyInfo 文件中
我已经进行了大量的谷歌搜索,但似乎无法找到将 TeamCity 内部版本号放入我的 AssemblyInfo 文件中的确切解决方案。希望能提供满足我的要求的完整解决方案...
1 将内部版本号放入 Nant 变量中。我相信这段代码将实现这一点..
PropertyGroup
Version$(BUILD_NUMBER)/Version
/PropertyGroup
(在SO中尽可能地重新发布)。
2 现在我需要一种方法来更新版本号的修订版组件,以便我得到类似 1.0.0.[内部版本号] 的内容。
3 理想情况下,我需要将整个内容放在可重用的 Nant 目标中,这样我就可以将其传递到我想要更新的程序集信息文件的路径中进行调用。
如果您能帮助我,我会恭敬地请求您在此处发布完整的解决方案并附上解释,而不是指向其他网站的链接。我查看了很多在线示例,但似乎找不到适合我需要的示例 - 因此我请求无所不能的 SO 社区的知识!
提前致谢。
I have done a lot of googling but cant seem to find an exact solution to get the TeamCity build number into my AssemblyInfo files. Would appreciate a full solution for my requirements...
1 Get the build number into a Nant variable. I believe that this code will accomplish this..
PropertyGroup
Version$(BUILD_NUMBER)/Version
/PropertyGroup
(repoduced as best as possible in SO).
2 Now I need a way to update the revision component of my version numbers so I get something like 1.0.0.[build number].
3 Ideally I need the whole thing in a re-usable Nant target so that I can just call it passing in the path to the assembly info file that i want to update.
I would respectfully request that if you can help me that a full solution is posted here with explanation as opposed to links to other sites. Ive looked at a lot of online examples but cant seem to find one that fits what I need - therefore I request the knowledge of the omnipotent SO community!
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您问题中的代码片段是 MSBuild 语法,而不是 NAnt。假设 NAnt 是您的构建工具,这里有关于如何使用 Cruise Control.NET 更新 AssemblyInfo 文件的很好的解释 此处。这也适用于 TeamCity,只需将“CCNetLabel”替换为“build.number”即可。
要获取 1.0.0.[内部版本号] 等版本号,您可以在 TeamCity 构建配置中完成此操作。在第一个配置页面(常规设置)。将“版本号格式”从“{0}”更改为“1.0.0.{0}”。有关更多选项,请参阅在线帮助。
First of all, the code snippet in your question is MSBuild syntax, not NAnt. Assuming that NAnt is your build tool, there is a good explanation of how to update AssemblyInfo files with Cruise Control.NET here. That applies to TeamCity as well, just replace "CCNetLabel" with "build.number" and you will be fine.
To get a version number like 1.0.0.[build number], you can accomplish that in the TeamCity build configuration. On the first configuration page (General Settings). Change the "Build Number Format" from "{0}" to "1.0.0.{0}". See the online help for more options.
我知道您要求 NAnt 可重用任务,但这太酷了。
TeamCity 有一个新的为此目的量身定制的功能 (AssemblyInfo Patcher)。
您不必更改 (NAnt) 构建中的任何内容。只需在构建的构建步骤配置中添加 AssemblyInfo 修补程序的“附加构建功能”即可。您还可以在那里设置版本的格式。
I know you asked for an NAnt reusable task, but this is too cool.
TeamCity has a new feature tailor-made for this purpose (AssemblyInfo Patcher).
You don't have to change anything in the (NAnt) build. Just add the "Additional Build Feature" for AssemblyInfo patcher in the Build Steps configuration for the build. You can also set the format for the version there.