Teamcity构建编号格式中的程序集版本号。

4
在我的程序集版本中,我想设置前三位数字,第四位应该通过Teamcity设置。
例如: 我在程序集中设置2.0.1.0。 然后我的Teamcity应该做到: 2.0.1.90, 2.0.1.91..。
目前我有: 2.0.1.%build.counter%
但我想要的是,2.0.1由我的程序集版本设置,而不是通过一个硬编码数字设置。

可能是 https://dev59.com/hWw05IYBdhLWcg3waRGz 或 https://dev59.com/OnM_5IYBdhLWcg3wzmgw 的重复。 - rmunn
1个回答

0
你使用的是哪个Teamcity版本?Teamcity 9.1有一个新的构建功能文件内容替换器,它允许您使用正则表达式替换文件内容。然而,早期版本的Teamcity没有内置此功能,因此对于它们,您需要自己编写,可能是一个PowerShell脚本或MSBuild目标。 MSBuild目标SetRevisionNumber的示例代码。
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask AssemblyFile="MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.FileUpdate" />

  <Target Name="SetRevisionNumber" Condition="$(RevisionNumber) != ''">
    <Message Text="Setting Revision Number to $(RevisionNumber) in $(AssemblyVersionFile)" Importance="High" />

    <FileUpdate Files="$(AssemblyVersionFile)"
      Regex="\[assembly: AssemblyVersion\(.(\d+)\.(\d+)\.(\d+)\.(\d+)"
      ReplacementText="[assembly: AssemblyVersion(&quot;$1.$2.$3.$(RevisionNumber)" />

  </Target>
</Project>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接