問題描述
我和我的團隊在增加程序集版本號方面非常糟糕,而且我們經常發布 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# 程序集版本?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!