正如有人所說,你可以構建腳本的執行過程中輸出的版本號,以及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>']
其實我使用從TeamCity的sln2008亞軍,也是我的標籤通過TeamCity的完成,以及在版本只輸出。所有其他自定義構建腳本在VS.NET項目中「可恥地」寫爲構建後腳本。 – 2009-06-24 22:00:31
我真正想要的標籤是指實際發佈版本,即人們下載和使用的版本。我認爲這是標記它的最簡單的方法。 – 2009-06-24 22:01:48