TfsVersion ClassMSBuild Extension Pack Help 4.0.12.0
Valid TaskActions are:

GetVersion (Required: TfsBuildNumber, VersionFormat Optional:Major, Minor, BuildNumberRegex, PaddingCount, PaddingDigit, StartDate, DateFormat, BuildName, Delimiter, Build, Revision, VersionTemplateFormat, CombineBuildAndRevision, UseUtcDateOutput: Version, Major, Minor, Build, Revision)

Please Note: The output of GetVersion should not be used to change the $(BuildNumber). For guidance, see: http://freetodev.spaces.live.com/blog/cns!EC3C8F2028D842D5!404.entry

SetVersion (Required: Version, Files Optional: TextEncoding, SetAssemblyVersion, AssemblyVersion, SetAssemblyFileVersion, ForceSetVersion

Remote Execution Support: NA

Inheritance Hierarchy

SystemObject
  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.VisualStudioTfsVersion

Namespace: MSBuild.ExtensionPack.VisualStudio
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

The TfsVersion type exposes the following members.

Constructors

  NameDescription
Public methodTfsVersion
Top
Properties

  NameDescription
Public propertyAssemblyVersion
Sets the AssemblyVersion. Defaults to Version if not set.
Public propertyBuild
Gets or Sets the Build version
Public propertyBuildName
Sets the name of the build. For Tfs 2005 use $(BuildType), for Tfs 2008 use $(BuildDefinition)
Public propertyBuildNumberRegex
Sets the BuildNumberRegex to determine the verison number from the BuildNumber when using in Synced mode. Default is \d+\.\d+\.\d+\.\d+
Public propertyCombineBuildAndRevision
Sets whether to make the revision a combination of the Build and Revision.
Public propertyDateFormat
Sets the date format to use when using VersionFormat="DateTime". e.g. MMdd
Public propertyDelimiter
Sets the Delimiter to use in the version number. Default is .
Public propertyFiles
Sets the files to version
Public propertyForceSetVersion
Set to true to force SetVersion action to update files that do not have AssemblyVersion | AssemblyFileVersion present. Default is false. ForceSetVersion does not affect AssemblyVersion when SetAssemblyVersion is false.
Public propertyMajor
Sets the major version
Public propertyMinor
Sets the minor version
Public propertyPaddingCount
Sets the number of padding digits to use, e.g. 4
Public propertyPaddingDigit
Sets the padding digit to use, e.g. 0
Public propertyRevision
Gets or Sets the Revision version
Public propertySetAssemblyFileVersion
Set to True to set the AssemblyFileVersion when calling SetVersion. Default is true.
Public propertySetAssemblyVersion
Set to True to set the AssemblyVersion when calling SetVersion. Default is false.
Public propertyStartDate
Sets the start date to use when using VersionFormat="Elapsed"
Public propertyTextEncoding
Sets the file encoding. Default is UTF8
Public propertyTfsBuildNumber
Sets the Tfs Build Number. Use $(BuildNumber) for Tfs 2005 and 2008.
Public propertyUseUtcDate
Set to True to get the elapsed calculation using UTC Date Time. Default is false
Public propertyVersion
Gets or Sets the Version
Public propertyVersionFormat
Sets the Version Format. Valid VersionFormats are Elapsed, DateTime, Synced
Public propertyVersionTemplateFormat
Specify the format of the build number. A format for each part must be specified or left blank, e.g. "00.000.00.000", "..0000.0"
Top
Examples

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <ItemGroup>
        <FilesToVersion Include="C:\Demo\CommonAssemblyInfo.cs"/>
    </ItemGroup>
    <Target Name="Default">
        <!-- Get a version number based on the elapsed days since a given date -->
        <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="GetVersion" BuildName="YOURBUILD" TfsBuildNumber="YOURBUILD_20080703.1" VersionFormat="Elapsed" StartDate="17 Nov 1976" PaddingCount="4" PaddingDigit="1" Major="3" Minor="5">
            <Output TaskParameter="Version" PropertyName="NewVersion" />
        </MSBuild.ExtensionPack.VisualStudio.TfsVersion>
        <Message Text="Elapsed Version is $(NewVersion)"/>
        <!-- Get a version number based on the format of a given datetime -->
        <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="GetVersion" BuildName="YOURBUILD" TfsBuildNumber="YOURBUILD_20080703.1" VersionFormat="DateTime" DateFormat="MMdd" PaddingCount="5" PaddingDigit="1" Major="3" Minor="5">
            <Output TaskParameter="Version" PropertyName="NewVersion" />
        </MSBuild.ExtensionPack.VisualStudio.TfsVersion>
        <Message Text="Date Version is $(NewVersion)"/>
        <!-- Set the version in a collection of files -->
        <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="SetVersion" Files="%(FilesToVersion.Identity)" Version="$(NewVersion)"/>
        <!-- Set the version in a collection of files, forcing AssemblyFileVersion to be inserted even if it was not present in the affected file -->
        <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="SetVersion" Files="%(FilesToVersion.Identity)" Version="$(NewVersion)" ForceSetVersion="true"/>
        <!-- Get a version number based on the elapsed days since a given date and use a comma as the delimiter -->
        <MSBuild.ExtensionPack.VisualStudio.TfsVersion TaskAction="GetVersion" Delimiter="," BuildName="YOURBUILD" TfsBuildNumber="YOURBUILD_20080703.1" VersionFormat="Elapsed" StartDate="17 Nov 1976" PaddingCount="4" PaddingDigit="1" Major="3" Minor="5">
            <Output TaskParameter="Version" PropertyName="NewcppVersion" />
        </MSBuild.ExtensionPack.VisualStudio.TfsVersion>
        <Message Text="C++ Version: $(NewcppVersion)"/>
    </Target>
</Project>
See Also

Reference