问题描述
我和我的团队在增加程序集版本号方面非常糟糕,而且我们经常发布 1.0.0.0 版本的程序集.显然,这会引起很多麻烦.
Myself and my group are horrendous at incrementing assembly version numbers and we frequently ship assemblies with 1.0.0.0 versions. Obviously, this causes a lot of headaches.
通过我们的 CI 平台,我们的实践变得更好了,我会真的很喜欢将其设置为自动增加 assemblyinfo.cs
文件中的值,以便我们的程序集版本随着该程序集中的代码更改自动更新.
We're getting a lot better with our practices via our CI platform and I'd really like to set it up to auto increment the values within the assemblyinfo.cs
file so that the versions of our assemblies are auto updated with the code changes in that assembly.
我之前设置了(在我们发现 Hudson 之前)一种递增方式通过 msbuild
或命令行(不记得)的值,但使用 Hudson,这将更新 SVN 存储库并触发另一个构建.由于 Hudson 每小时轮询 SVN,这将导致缓慢的无限循环.
I had previously setup (before we found Hudson) a way to increment the value through either msbuild
or the command line (can't remember), but with Hudson, that will update the SVN repository and trigger ANOTHER build. That would result in a slow infinite loop as Hudson polls SVN every hour.
让 Hudson 增加版本号是个坏主意吗?有什么替代方法可以做到这一点?
Is having Hudson increment the version number a bad idea? What would be an alternative way to do it?
理想情况下,我的解决方案标准应该是:
Ideally, my criteria for a solution would be one that:
- 在构建之前增加
assemblyinfo.cs
中的构建号 - 仅增加已更改程序集中的内部版本号.这可能是不可能的,因为 Hudson 每次构建时都会清除项目文件夹
- 将更改后的 assemblyinfo.cs 提交到代码库(当前为 VisualSVN)
- 不会导致 Hudson 在下次扫描更改时触发新构建
在我的脑海中解决这个问题后,我可以通过批处理文件/命令轻松地想出解决大部分问题的方法,但我的所有想法都会导致 Hudson 在下次扫描时触发新构建.我不是在找人为我做所有事情,只是为我指明正确的方向,也许是一种让 Hudson 忽略某些 SVN 提交的技术,等等.
Working this out in my head, I could easily come up with a solution to most of this through batch files / commands, but all of my ideas would cause Hudson to trigger a new build the next time it scans. I'm not looking for someone to do everything for me, just point me in the right direction, maybe a technique to get Hudson to ignore certain SVN commits, etc.
到目前为止,我发现的所有内容都只是一篇解释如何让版本号自动递增的文章,没有考虑到可能陷入无限循环的 CI 平台.
Everything I've found so far is just an article explaining how to get the version number automatically incremented, nothing takes into account a CI platform that could be spun into an infinite loop.
推荐答案
一个简单的替代方法是让 C# 环境通过将 version 属性设置为 major.minor.*
为您增加程序集版本(如 AssemblyInfo 文件模板中所述.)
A simple alternative is to let the C# environment increment the assembly version for you by setting the version attribute to major.minor.*
(as described in the AssemblyInfo file template.)
不过,您可能正在寻找更全面的解决方案.
You may be looking for a more comprehensive solution, though.
编辑(在评论中回复问题):
EDIT (Response to the question in a comment):
来自 AssemblyInfo.cs
:
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
这篇关于如何通过我们的 CI 平台 (Hudson) 自动增加 C# 程序集版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!