如何在TeamCity中生成自定义内部版本号,然后将其修补到程序集信息? [英] How can I generate a custom build number in TeamCity and then patch it to assembly info?
问题描述
我已经在这个主题上进行了一些搜索,并且能够找到单独的解决方案来生成自定义内部版本号以及补丁程序集信息,但是我无法同时实现这两者.使用在搜索中找到的自定义POWERSHELL脚本时,我可以将内部版本号设置为使用该脚本创建的内部版本号,但是此内部版本号不会修补.我打补丁的唯一成功是使用设置数字和计数器.但是,POWERSHELL脚本创建的数字不能持续到程序集修补程序可以使用的程度.我做错了吗?
I have done some searching on this topic and am able to find individual solutions to generate custom build numbers as well as patch assembly info, however I am unable to accomplish both. When using a custom POWERSHELL script that I found in a search, I am able to set the build number to what I create with the script, however this build number does not patch. The only success I have in patching is when using set numbers plus a counter. But the number that the POWERSHELL script creates does not persist to an extent that the Assembly patcher can work with. Am I doing it wrong?
推荐答案
我终于用Chaitanya提供的一点逻辑来解决了这个问题……但进行了修改:
I finally solved it with a little bit of Chaitanya's provided logic... but modified:
$ww = ([Math]::Floor([DateTime]::Now.DayOfYear/7)+1)
Write-Host "##teamcity[buildNumber '%major.minor%.$ww.%build.counter%']"
$fileLocation = Join-Path -Path "%teamcity.build.checkoutDir%" -ChildPath "\SourceDir\AssemblyInfo.cs"
$oldValue = "AssemblyFileVersion\(""(\d+)\.\d+\.\d+\.\d+""\)"
$newValue = [string]::Concat("AssemblyFileVersion(""%major.minor%.", $ww, ".%build.counter%", """)")
(get-content $fileLocation) | foreach-object {$_ -replace $oldValue, $newValue} | set-content $fileLocation
这篇关于如何在TeamCity中生成自定义内部版本号,然后将其修补到程序集信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!