Customize Team Build 2010 – Part 16: Specify the relative reference path

by Ewald Hofman 6. April 2011 05:56

In the series the following parts have been published

  1. Part 1: Introduction
  2. Part 2: Add arguments and variables
  3. Part 3: Use more complex arguments
  4. Part 4: Create your own activity
  5. Part 5: Increase AssemblyVersion
  6. Part 6: Use custom type for an argument
  7. Part 7: How is the custom assembly found
  8. Part 8: Send information to the build log
  9. Part 9: Impersonate activities (run under other credentials)
  10. Part 10: Include Version Number in the Build Number
  11. Part 11: Speed up opening my build process template
  12. Part 12: How to debug my custom activities
  13. Part 13: Get control over the Build Output
  14. Part 14: Execute a PowerShell script
  15. Part 15: Fail a build based on the exit code of a console application
  16. Part 16: Specify the relative reference path


As I have already blogged about, it is not intuitive how to specify the paths where the build server has to look for references that are stored in Source Control. It is a common practice to store 3rd party libraries in Source Control, so they are available to everyone, everyone uses the same version of the libraries and updating a library can be done centrally.

In Team Build 2010 these paths are specified as a parameter for MSBuild. What we will do in this post is building the values for this parameter based on the values in an argument. You are now pretty aware how to customize the build template, so let’s do the modifications in another way. Instead of opening the xaml file in the workflow designer, we open it in the XML editor. You can open it in the XML Editor by either selecting the Open with menu (see the context menu), or by choosing the View code option.

To add this functionality we need to:

  1. Specify a new argument
  2. Add the argument to the metadata
  3. Build the absolute paths for the references and add these paths to the MSBuild arguments

1. Specify a new argument

Locate at the top of the document the Members (which are the arguments) of the XAML

image

and add the following line

<x:Property Name="ReferencePaths" Type="InArgument(s:String[])" />

image

2. Add the argument to the metadata

Then locate the line

<mtbw:ProcessParameterMetadataCollection>

and paste the following line

<mtbw:ProcessParameterMetadata Category="Misc" Description="The list of reference paths, relative to the root path in the Workspace mapping." DisplayName="Reference paths" ParameterName="ReferencePaths" />
image

3. Build the absolute paths for the references and add these paths to the MSBuild arguments

Now locate the place where the assignments are done to the variables used in the agent.

image

And add the following lines after the last Assign activity

        <Sequence DisplayName="Initialize ReferencePath" sap:VirtualizedContainerService.HintSize="464,428">
          <Sequence.Variables>
            <Variable x:TypeArguments="x:String" Name="ReferencePathsArgument">
              <Variable.Default>
                <Literal x:TypeArguments="x:String" Value="" />
              </Variable.Default>
            </Variable>
          </Sequence.Variables>
          <sap:WorkflowViewStateService.ViewState>
            <scg:Dictionary x:TypeArguments="x:String, x:Object">
              <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            </scg:Dictionary>
          </sap:WorkflowViewStateService.ViewState>
          <ForEach x:TypeArguments="x:String" DisplayName="Iterate through the paths" sap:VirtualizedContainerService.HintSize="287,206" mtbwt:BuildTrackingParticipant.Importance="Low" Values="[ReferencePaths]">
            <ActivityAction x:TypeArguments="x:String">
              <ActivityAction.Argument>
                <DelegateInArgument x:TypeArguments="x:String" Name="path" />
              </ActivityAction.Argument>
              <Assign x:TypeArguments="x:String" DisplayName="Build ReferencePath argument" sap:VirtualizedContainerService.HintSize="257,100" mtbwt:BuildTrackingParticipant.Importance="Low" 
To="[ReferencePathsArgument]" Value="[If(String.IsNullOrEmpty(ReferencePathsArgument), &quot;&quot;, ReferencePathsArgument + &quot;;&quot;) + IO.Path.Combine(SourcesDirectory, path)]" />             </ActivityAction>           </ForEach>           <Assign DisplayName="Append the reference paths to the MSBuild Arguments" sap:VirtualizedContainerService.HintSize="287,58">             <Assign.To>               <OutArgument x:TypeArguments="x:String">[MSBuildArguments]</OutArgument>             </Assign.To>             <Assign.Value>               <InArgument x:TypeArguments="x:String">[String.Format("{0} /p:ReferencePath=""{1}""", MSBuildArguments, ReferencePathsArgument)]</InArgument>             </Assign.Value>           </Assign>         </Sequence>

Now you can use the template to specify the paths relative to SourcesDirectory.


You can download the full solution at BuildProcess.zip. It will include the sources of every part and will continue to evolve.

Tags:

Team Build | VS 2010

Comments

4/6/2011 6:00:33 AM #

trackback

Where is the AdditionalReferencePath in TFS 2010?

Where is the AdditionalReferencePath in TFS 2010?

Ewald Hofman |

4/7/2011 4:13:09 AM #

Ed Blankenship

Hi Ewald!

Thanks for putting this together!  For translating the local location, it may change based on the workspace definitions for the build.  What I found is the best is to ask for a server path location and use the ConvertWorkspaceItem or CovertWorkspaceItems build activity (available out of the box) to convert the server path(s) to their corresponding local paths.  You don't have to worry about using the Assign activity as you did above to concatenate it with the Sources directory.

I have an example where I'm asking the build definition editor to specify each of the work item type definition XML files as server paths (even using the Version Control repository browser).  That example is in the "Deploying Process Template Changes" build process template available here:  www.edsquared.com/.../...Using+TFS+2010+Build.aspx

Ed B.

Ed Blankenship United States |

4/7/2011 4:51:10 AM #

Ewald Hofman

Ed,

Thanks for the feedback, and a very good suggestion.

So to be clear about this, you are saying that you want to store the server paths in the reference argument. And then use the ConvertWorkspaceItem to convert that server path into a local path on the build server?

It is another way of looking at the problem. But how do you handle supporting different branches? When I now use the build definition for another branch, I only have to modify the workspace and the "items to build". In your case you have to modify the references argument too.

Please correct me if I am wrong.

Ewald Hofman Netherlands |

4/7/2011 5:40:15 AM #

Ed Blankenship

Completely understandable question.

I find that people are more familiar with the concept of a server path rather than where it is going to be locally downloaded on the build server.  That's often because the people who are editing the build definition may not have the ability to login to the build server(s) locally to understand the location where it will be downloaded locally.

As far as changing it for new build definitions based on new branches, it's super easy especially if you use the StringList and StringListEditor.  You can "clone" the build definition using the Power Tools and then open the string list editor and replace the branch name.  Simple as that...  You often have to do this activity anyway with the solutions & projects to build any way so this is just an added factor to that existing activity.

Ed Blankenship United States |

4/8/2011 5:09:09 AM #

pingback

Pingback from learntfs.com

April 8, 2011 – VS/TFS Links and Quick Hits | Learn TFS

learntfs.com |

4/20/2011 10:00:00 PM #

pingback

Pingback from pontocom.net

Encontrado por aí (II) | pontocom.net

pontocom.net |

4/20/2011 10:11:25 PM #

pingback

Pingback from celulareaminhavida.wordpress.com

iPhone 4 branco ? Lançamento em 2011 | Celular é minha vida

celulareaminhavida.wordpress.com |

4/20/2011 10:29:34 PM #

pingback

Pingback from barrigadefinida.wordpress.com

Contagem decrescente… | barrigadefinida

barrigadefinida.wordpress.com |

4/20/2011 10:29:41 PM #

pingback

Pingback from musicaesbela.wordpress.com

Bon Jovi: no Rio um show bom, mas poderia ter sido melhor | musicaesbela

musicaesbela.wordpress.com |

4/20/2011 11:12:10 PM #

pingback

Pingback from bebesecriancas.wordpress.com

POR QUÊ? | bebes e criancas

bebesecriancas.wordpress.com |

4/20/2011 11:16:01 PM #

pingback

Pingback from caionalves4.wordpress.com

Roxette leva fãs ao delírio | caionalves4

caionalves4.wordpress.com |

5/31/2011 8:22:25 AM #

trackback

Ewald’s posts on TFS Build 2010

Ewald Hofman , an ALM MVP, has written a great series of blog posts on Team Build in Team Foundation Server 2010.  The 2010 release introduces Windows Workflow as the overall orchestrator of the build process.  Ewald walks you through quite a few topics related to this and the other new features.  Check it out! Part 1: Introduction Part 2: Add arguments and variables Part 3: Use more complex arguments Part 4: Create your own activity Part 5: Increase AssemblyVersion Part 6: Use custom type for an argument Part 7: How is the custom assembly found Part 8: Send information to the build log Part 9: Impersonate activities (run under other credentials) Part 10: Include Version Number in the Build Number Part 11: Speed up opening my build process template Part 12: How to debug my custom activities Part 13: Get control over the Build Output Part 14: Execute a PowerShell script Part 15: Fail a build based on the exit code of a console application Part 16: Specify the relative reference path Technorati Tags: tfs 2010 , team build , windows workflow

Buck Hodges |

10/2/2011 6:59:45 PM #

pingback

Pingback from museudopc.com

CARTÃO HAVAN | museudopc.com

museudopc.com |

8/17/2013 2:52:33 AM #

trackback

ALM for SharePoint Apps: Customizing the Build Process with a Custom Workflow Activity

This post shows how to create a custom customize the build process for provider-hosted apps with a custom

Kirk Evans Blog |

Comments are closed

Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen


ClusterMap

Statistics

Statistics created at 09 Sep 2009

121 posts
488 comments
326 raters
1884298 visit (1042 per day)
19 users online

Recent comments

Comment RSS