Mike's profileFreeToDevBlogLists Tools Help

Blog


    July 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>


    July 20

    Integrate Microsoft C# Source Analysis with TFS --- Republished

    The FTDSourceAnalysis task is now available again. This task works with Source Analysis 4.2. A version for StyleCop 4.3 will be made available in the FreeToDev MSBuild Tasks Suite soon...

    July 16

    FreeToDev MSBuild Tasks Suite 3.5.11564.0 (beta) Released

    A new beta of the FreeToDev MSBuild Tasks Suite is now available on CodePlex... FreeToDev
    July 12

    Introducing the FreeToDev MSBuild Tasks Suite

    Logo BackGround with Text (smaller)

    The first beta of the FreeToDev MSBuild Tasks Suite is now available on CodePlex

    banner_logo

    Download from here: http://www.codeplex.com/freetodevtasks

    The Suite provides over 70 tasks covering the .Net Framework, IIS7, Team Foundation Server, WMI and more.
    Every task is provided with clear documentation and a working sample. Where applicable, tasks also provide remote support, e.g. IIS7, GAC etc.

    The Suite can be installed via an MSI installer for easy and consistent deployment. There will be frequent updates to the tasks over the next few weeks to provide additional remote support, new tasks and better documentation, so keep an eye on progress and provide as much feedback as you can via the Discussions and Issue Tracker pages.

    There are quite a few tasks missing from the first beta drop and the documentation isn't as clear as I would like, however I expect to have this all resolved during the future betas and full release due in August 2008.

    FreeToDev