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 (9)

  1. Simon Burgess says:

    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

  2. nagarajp says:

    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.

  3. Mads says:

    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

  4. Fredrik Gunne says:

    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?

  5. nagarajp says:

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

  6. Matt Faus says:

    Have you ever opened Team Explorer to kick off a build and watched in awe as the server stayed in the

Skip to main content