Mike 的个人资料FreeToDev日志列表 工具 帮助

日志


7月24日

Versioning Code in TFS - Part 2

7 Nov 2009: Update

In Versioning Code in TFS - Part 1 I covered most of my thoughts on the matter. I've since helped a colleague out with implementing code versioning using GetBuildNumber and SetBuildNumber in the FTDTFSBuild task. I was disappointed that the experience wasn't as smooth as it could have been and following a few discussions, a few changes have been made to the FTDTFSBuild Task to improve the functionality and user experience. These have all shipped in the latest beta release of the FreeToDev MSBuild Tasks Suite.

Summary of Changes

Name changes to alleviate confusion:
  • FTDTFSBuild ---> FTDTFSVersion
  • GetBuildNumber ---> GetVersion
  • SetBuildNumber ---> SetVersion
  • BuildType ---> BuildName
  • BuildNumber & CalculatedBuildNumber ---> Version
  • Encoding ---> TextEncoding to be consistent with other tasks
  • Format ---> VersionFormat
  • VersionFormat Date option ---> DateTime
Enhancements
  • ZeroPadding has been split into PaddingCount and PaddingDigit
  • Padding is now supported for VersionFormat=”DateTime”, not just VersionFormat=”Elapsed”
  • TextEncoding is now optional. Defaults to UTF8
  • If a file is made write-able, it is now set back to read-only after versioning
Updated Sample

    <!-- 1. Import the Tasks-->
    <Import Project="C:\Program Files\FreeToDev\MSBuild Tasks Suite 3.5\FreeToDev.MSBuild.tasks"/>
    <ItemGroup>
        <!-- 2. Create an Item Collection of files to version -->
        <FilesToVersion Include="C:\POC\AssemblyInfo.cs"/>
    </ItemGroup>
    <!-- Team Build Code omitted for brevity -->
    <Target Name="BuildNumberOverrideTarget" Condition="'$(IsDesktopBuild)'!='true'">
        <!-- 3a. Get the version using the current Team Build properties. This example uses the Elapsed VersionFormat. Note, if you are using TFS2005, then use $(BuiltType) rather than $(BuildDefinition) for the BuildName property-->
        <FTDTFSVersion TaskAction="GetVersion" BuildName="$(BuildDefinition)" TFSBuildNumber="$(BuildNumber)" VersionFormat="Elapsed" StartDate="1 Jan 2000" PaddingCount="4" PaddingDigit="1" Major="3" Minor="5">
            <Output TaskParameter="Version" PropertyName="NewVersion"/>
        </FTDTFSVersion>
        <Message Text="Elapsed Version is $(NewVersion)"/>
        <!-- 3b. This example uses the DateTime VersionFormat. Note, if you are using TFS2005, then use $(BuiltType) rather than $(BuildDefinition) for the BuildName property-->
        <FTDTFSVersion TaskAction="GetVersion" BuildName="$(BuildDefinition)" TFSBuildNumber="$(BuildNumber)" VersionFormat="DateTime" DateFormat="MMdd" PaddingCount="5" PaddingDigit="1" Major="3" Minor="5">
            <Output TaskParameter="Version" PropertyName="NewVersion"/>
        </FTDTFSVersion>
        <Message Text="Date Version is $(NewVersion)"/>
    </Target>
    <Target Name="AfterGet" Condition="'$(IsDesktopBuild)'!='true'">
        <!-- 4. Set the version in the file collection -->
        <FTDTFSVersion TaskAction="SetVersion" Files="%(FilesToVersion.Identity)" Version="$(NewVersion)"/>
    </Target>


评论

请稍候...
很抱歉,您输入的评论太长。请缩短您的评论。
您没有输入任何内容,请重试。
很抱歉,我们当前无法添加您的评论。请稍后重试。
若要添加评论,需要您的家长授予您相应权限。请求权限
您的家长禁用了评论功能。
很抱歉,我们当前无法删除您的评论。请稍后重试。
您已超过了一天之内允许提供的评论数上限。请在 24 小时后重试。
因为我们的系统表明您可能在向其他用户提供垃圾评论,您的帐户已禁用了评论功能。如果您认为我们错误地禁用了您的帐户,请联系 Windows Live 支持部门
完成下面的安全检查,您提供评论的过程才能完成。
您在安全检查中键入的字符必须与图片或音频中的字符一致。
FourieMike 在此页禁用了评论功能。

引用通告 (1)

此日志的引用通告 URL 是:
http://freetodev.spaces.live.com/blog/cns!EC3C8F2028D842D5!547.trak
引用此项的网络日志