2011-11-01 45 views
4

我們的Teamcity版本當前生成的版本號格式爲1.0.0。[SVN REVISION],它傳遞給MSBUILD。Teamcity自定義內部版本號生成器

我需要將其更改爲格式1.0。[DLL版本]。[SVN REVISION]我們插入一個依賴dll的de-dotted版本。例如,如果我們的依賴dll是版本1.2.3.4生成內部版本號爲1.0.1234 [SVN版本]。

依賴的DLL是構建源的一部分,所以我希望我可以做一些構建參數和一個小的exe,它將它集成到版本信息中,但看不到任何方式通過UI來併入。

任何想法,如果這是可能的?

回答

10

您可以在構建腳本的執行過程中輸出構建編號,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>']

+0

這就是我需要的正是在版本只輸出。謝謝! – Matt

+0

此功能的當前文檔是[here](https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingBuildNumber)。 –

相關問題