Как уже упоминалось, вы можете вывести номер сборки во время выполнения скрипта сборки, и teamcity будет использовать этот вывод для маркировки сборки. Например, я помечаю свою сборку той же версией, которую я поместил в AssemblyInfo.cs. Часть этой версии (Major, Minor) уже находится в файле, другая часть (Build, Revision) добавляется во время сборки.
Из моего скрипта msbuild:
<Target Name="Setup">
<!-- Version.txt contains the major and minor version numbers,
The build number and revision come from environment variables
in the next step -->
<Version VersionFile="Version.txt" BuildType="None" RevisionType="None">
<Output TaskParameter="Major" PropertyName="Major" />
<Output TaskParameter="Minor" PropertyName="Minor" />
</Version>
<!-- If you want to build a release without going through the build
server, you should define the following 2 environment variables
when running this build script -->
<!-- BUILD_NUMBER environment variable supplied by the build server -->
<CreateProperty
Value="$(BUILD_NUMBER)">
<Output
TaskParameter="Value"
PropertyName="Build" />
</CreateProperty>
<!-- BUILD_VCS_NUMBER environment variable supplied by the build server -->
<CreateProperty
Value="$(BUILD_VCS_NUMBER)">
<Output
TaskParameter="Value"
PropertyName="Revision" />
</CreateProperty>
<AssemblyInfo CodeLanguage="CS"
OutputFile="Properties\VersionInfo.cs"
AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)" />
<!-- Tell the build server what our actual build number is -->
<Message Text="##teamcity[buildNumber '$(Major).$(Minor).$(Build).$(Revision)']" />
</Target>
вы просто выводите версию во время сборки в формате ##teamcity[buildNumber '<buildnum>']