Jaa


Examining Get Task in TeamBuild

TeamBuild implemented ‘Get’ task for syncing sources. This task is same as ‘tf get’ , the command line utility to sync sources.

Properties Supported by Get Task

Workspace

The workspace used to get sources

Version

You can specify a version by:

  • Date/time (D10/20/2005)
  • Changeset version (C1256)
  • Label (Lmylabel)
  • Latest version (T)
  • Workspace version (Wworkspacename;owner)
  • If no version is provided, Team Build retrieves the latest server version of the specified filespec into your workspace.

by default, it is ‘T’, get latest sources.

FileSpec

items that need to be fetched. It is ‘*’, by default

Recursive

Recursively retrieves all items that match your filespec

Force

Overwrite files

The default build type uses this task to get the latest sources. However, you can very easily customize Get task to sync what you want. To do this, you will need to override the CoreGet target implemented in TeamBuild targets file Microsoft.TeamFoundation.Build.targets. I typically copy a target that I want to override into TfsBuild.proj of my build type and make changes appropriately. In this case, I copied CoreGet target into my TfsBuild.proj and played with it. I’m providing some examples below. This is a very powerful task. You can use the options Version and FileSpec in conjuction to get any sources

of any version.

 

Getting Labled Sources

The following example gets the sources labeled with “Beta1” and builds.

<Target Name="CoreGet"

Condition=" '$(IsDesktopBuild)'!='true' "

DependsOnTargets="$(CoreGetDependsOn)" >

<Get

Condition=" '$(SkipGet)'!='true' "

Workspace="$(WorkspaceName)"

Recursive="$(RecursiveGet)"

Version="LBeta1"

Force="$(ForceGet)" />

<!-- Label all files in the workspace to identify sources used in this build -->

<Label

Condition=" '$(SkipLabel)'!='true' "

Workspace="$(WorkspaceName)"

Name="$(BuildNumber)"

Version="W$(WorkspaceName)"

Files="$/$(TeamProject)"

Recursive="true" />

</Target>

Getting a Particular Changeset into TeamBuild

The following example gets the sources labeled with “Beta1” and gets Porgram.cs that was checked in with changeset 26.

<Target Name="CoreGet"

Condition=" '$(IsDesktopBuild)'!='true' "

DependsOnTargets="$(CoreGetDependsOn)" >

<Get

Condition=" '$(SkipGet)'!='true' "

Workspace="$(WorkspaceName)"

Recursive="$(RecursiveGet)"

Version="LBeta1"

Force="$(ForceGet)" />

<Get

Condition=" '$(SkipGet)'!='true' "

FileSpec="$/ScoutingTest/HelloWorld/Program.cs"

Workspace="$(WorkspaceName)"

Recursive="$(RecursiveGet)"

Version="C26" />

<!-- Label all files in the workspace to identify sources used in this build -->

<Label

Condition=" '$(SkipLabel)'!='true' "

Workspace="$(WorkspaceName)"

Name="$(BuildNumber)"

Version="W$(WorkspaceName)"

Files="$/$(TeamProject)"

Recursive="true" />

</Target>

Namaste!

Comments

  • Anonymous
    October 30, 2005
    Is there somewhere central we can get the documentation like that above for the 'Get' task for all the other tasks in Microsoft.TeamFoundation.Build.Tasks.*.dll

  • Anonymous
    November 07, 2005
    Hi Simon, we currently don't have product documentation on tasks. I'll try to provide as many details as possible on all tasks through my blog. Thanks.

  • Anonymous
    January 25, 2006
    A sample showing excluding paths from the source control tree would be really helpful considering that coreget pulls the entire tree from source control. thanks!mads

  • Anonymous
    February 21, 2006
    I need to add an extra "get", in addition to the default "get". Is there a way of overriding the CoreGet target, such that the default "get" is called?
    If not, how do I modify my own "get", such that it does what the default "get" does already?

  • Anonymous
    February 28, 2006
    Hi Fedrick, you can override AfterGet target and add custom Get task. This target gets called after CoreGet target and should serve your purpose.

  • Anonymous
    January 31, 2007
    Configuration and Management of Team Foundation Server http://msdn.microsoft.com/vstudio/teamsystem/team/quickstarts/configure/default.aspx

  • Anonymous
    July 09, 2007
    Have you ever opened Team Explorer to kick off a build and watched in awe as the server stayed in the

  • Anonymous
    March 02, 2008
    PingBack from http://www.vsts.or.kr/blog/?p=37

  • Anonymous
    March 27, 2009
    PingBack from http://jmalinovskis.wordpress.com/2009/03/27/msbuild-tfs-links/