Build Customization using Visual Studio 2010

Posted by: Gouri Sohoni , on 4/13/2010, in Category Visual Studio, VSTS & TFS
Views: 54636
Abstract: Visual Studio 2010 RTM released yesterday and we are all excited about the new features it brings with it. In this article, we will explore the new features and functionality in Visual Studio 2010 for Build Management and Customization.
Build Customization using Visual Studio 2010
 
Visual Studio 2010 RTM released yesterday (April 12th) and we are excited about the new features it brings with it. In this article, we will explore the new features and functionality in Visual Studio 2010 for Build Management and Customization.
Microsoft has provided lot of new features and functionality with Visual Studio 2010 for Build Management and Customization. Let me list some of those new features first.
1.    The process uses workflow foundation based workflow as an engine to execute build. It has xaml based process templates. There is a graphical interface provided with which we can customize the existing process. There are 3 templates provided in the box, namely DefaultTemplate.xaml (normal process template), UpgradeTemplate.xaml (if you already have build definition created with Visual Studio 2005 or 2008) and LabDefaultTemplate.xaml (to be used for builds with lab management).
2.    Using these templates, there can be multiple definitions created for builds. Each will defer upon various parameters like what is trigger for build, where to drop the build executables and log files, what items to build, which controller is responsible for build etc.
3.    A trigger named ‘Gated Check-in’ is provided so as to avoid build failure because of a problem in code. In Gated Check-in, the pre-defined build gets executed at the time of every check-in and the check-in is successful only if that build is successful. This trigger can be normally incorporated as a part of agile methodology. In this methodology, an application feature is completed first and only then the check-in is done. So we can provide build for each check-in (continuous integration) and check whether the build is a failure or not.
4.    As a part of the build report, we can get a list of impacted tests (the tests which need to be run again because of some change in code). This can avoid regression.
5.    We can see all the results of code coverage with the summary provided with build.
The default workflow for build definition is as follows :
Sequence
Build Process Customization:
If we want to add some more activities as a part of the existing process template, there are various ways with which the customizations can be specified.
1.    By dragging and dropping existing (predefined) activities from the toolbox and configuring them as required.
2.    By creating your own activity by using “Activity Library” with the help of xaml only.
3.    By creating your own activity by using “Activity Library” but writing code in it.
We will discuss in detail how to customize the template in this article.If we require certain functionality which is not available directly with the default template we can customize the process. In this article we are going to create a backup folder for build drops for usage as latest builds.
1.    When we want to change the existing workflow for the template it is recommended that we create a copy of the existing xaml and work with it rather than changing in the default itself.
2.    The copy of existing xaml can be created at the time of creation of a new build definition as shown below:
SourceControlExplorer
With the process tab selected, click on ‘show details’ and select New button (the image shows ‘Hide Details’ as it is a toggle control)
0NewbuildDefinition

Provide the name for the custom template in the area for ‘New File name’
NewBuildProcessTemplate
3.    Once a copy is created, check-out the copy for edit and ‘Get Latest’. Provide a name of the local folder to map.
 
4.    Select the activity from the toolbox and drop it at the required location in the workflow. In this case, we are creating a backup copy of the build drop. In order to do so, we need to provide the location for “Copy directory” at the place where the drop location is created and the required executables and log files are ready so as to use the same to drop in another location. It is shown with the highlighter in the following diagram
RevertWorkshop
We can also see that the “Copy Files to Drop Location” activity is over at this stage.
DropBuild

Now we need to provide the source and destination for the activity “Copy Directory”. We have given the source as “BuildDetail.DropLocation” and a folder name for destination.
5.    Finally we can queue the build definition which is based on the custom xaml we created to see that the build drops copy of the executables and log files at the specified location. Nice!
In the upcoming articles, we will discuss two more ways of customizing build definition template in Visual Studio 2010.
If you liked the article,  Subscribe to the RSS Feed or Subscribe Via Email 
Gouri has an experience of over two decades in training and consulting. She is a Microsoft Certified Trainer (MCT) and conducts training and consulting on Microsoft technologies like Visual Studio 2010 (ALM), SQL Server 2005/2008 BI and SQL Server 2005/2008 developer track.
Give a +1 to this article if you think it was well written. Thanks!
Recommended Articles
Gouri Sohoni is a Microsoft MVP, Trainer and consultant for over two decades. She is a Microsoft Certified Trainer (MCT), MCITP and has conducted several corporate trainings on Microsoft technologies that include Visual Studio 2010 (ALM), SQL Server 2008 BI, SQL Server 2008 developer track, SQL Server 2005 BI, SQL Server 2005 developer track etc.


Page copy protected against web site content infringement by Copyscape


User Feedback
Comment posted by Karl on Wednesday, April 14, 2010 8:54 AM
Good article. Any Changes from VS 2008?
Comment posted by Gouri Sohoni on Tuesday, April 20, 2010 4:38 AM
Hi Karl,
Thanks for your comments.
The entire article is focussed on build in VS 2010 only. Right in the beginning of this article I have mentioned 5 changes from build in VS 2008 to build in VS 2010.
Comment posted by Allen Feinberg on Wednesday, May 19, 2010 4:13 PM
Gouri,
     I'm new to 2010 and I'm still trying to get my head wrapped around the xaml change. I'm trying to do the following: http://social.msdn.microsoft.com/Forums/en/tfsbuild/thread/030a9cc7-4c91-4132-a9fa-0fbcf119218d , can you in your next article point out something simple like this?
Comment posted by Toni on Thursday, August 5, 2010 3:44 AM
One question,
I need to exclude web.config because I have different configuration in my destination folder.
How can I do this? In my scenario I can't use deployment :(
Thanks!
Comment posted by Toni on Thursday, August 5, 2010 4:33 AM
One question,
I need to exclude web.config because I have different configuration in my destination folder.
How can I do this? In my scenario I can't use deployment :(
Thanks!
Comment posted by ElCorbo on Monday, December 12, 2011 9:35 AM
Thanks Gouri!  This article is very helpful.  I am working to leverage this information to publish new builds to our integration web farms.  I am close, but need to be able to copy just the contents of a subfolder within the build files in the drop location, instead of all of the files and folders.  Will post here if I find the solution!  Craig
Comment posted by lokesh.vastrad on Thursday, March 8, 2012 11:01 PM
Hi Gouri, my requirement is to create a new folder "Deployables" after the build folder. Not sure how to include this in the workflow. I tried to create a new directory but how can I name it as Deployables?

This is required as my deployment tool is looking for the executables under deployables folder.

Please help me out with this.

Thanks,
Lokesh
Comment posted by Rishi on Thursday, October 4, 2012 12:30 PM
could you please let me know how to change the activity diagram to place a merge and branch activity? TFS automated merge and branch.

Post your comment
Name:  
E-mail: (Will not be displayed)
Comment:
Insert Cancel