How to get SystemRoot folder during TFS Build


Getting the System Root Directory during TFS Build was not straightforward as I thought, so I decide to share my experience on how to get that.

  • I used InvokeMethod activity, in the Target Type I will put the name of the static class that has the method I need use.
  • In MethodName, I will put GetEnviornmentVariable.
  • Write the value to the build log by calling WriteBuildError and past the value return from GetEnviornmentVariable.

6-25-2014 12-53-38 PM

6-25-2014 12-58-59 PM

Note:
For InvokeMethod activity, if I need to call a method from an instance object then I will use Target Object not Target Type.

 

 

How to Call a batch file from TFS2013 Build?


I run into a situation which needed to run a batch file from TFS Build, this batch file downloads some files from a file server and I just needed to copy that files later during the same build process to another machine.

I will simulate that by creating a batch file that create a file and copy the created file to another machine.

Here is the batch file that create a new text file.
6-22-2014 10-19-33 PM
If I just double click on that file, it will create  a new file called NewFile.txt.
6-18-2014 11-22-07 AM

  1. Open any Build Process Template and delete all its activities.
  2. Add Sequence Activity with name: Overall Build Process.
  3. Drag and drop GetBuildDetail Activity inside the Sequence Activity.
  4. Drag and drop AgentScope Activity with name: Run on Agent.
  5. Drag and drop GetBuildDirectory Activity inside AgentScope Activity.
  6. Drag and drop InvokeProcess Activity with name: Call a batch file.
  7. Declare variable of type IBuildDetail with name: MyBuildDetail,and assign the return value from GetBuildDetail to it.
  8. Declare variable of type String with name: MyBuildDirectory,and assign the return value from GetBuildDirectory to it. More information on how to assign a value to variable from the return execution of activity

6-18-2014 10-33-40 AM

We need to include the folder that contains the script or the batch file in the Source Settings of our Build Definition; so the build server copy it in the working directory of the build.

But first, let’s remember what is the working directory of the build, it’s a folder like a temp folder the build process uses to get the last change set so it could build it, we configure that from TFS Administration Console for the agent.
6-18-2014 11-16-11 AM
So we will need to include the folder that contains the script or the batch file in the Source Settings of our Build Definition.
6-18-2014 11-13-02 AM

So now if we run this build, we will find that it gets the last change set including the script.
6-18-2014 11-17-43 AM

So now I can give the InvokeProcess Activity the path on the working directory as the following.
6-18-2014 11-02-17 AM

Remember if I run the build, the file will not be created in related path, but it will be in System 32 folder
6-18-2014 11-21-38 AM

Then I will need to copy that file to the needed machine, see the following post for typical steps.

How to Copy Build output to a Lab Environment Machine for TFS2013

How to Copy Build output to a Lab Environment Machine for TFS2013


If you want to run Coded-UI test on Lab Environment machine then you need to copy the binaries files to that machine, you can create script that do that but also you can create some customization for the build process to do that as the following.

In our scenario we have 2 machines, the first one (Visual Studio 2013 ALM RTM) it’s a TFS machine with Test Control and the second one (Agent) it’s a machine with Test Agent.
Machines
The first step on the Agent machine, share the folder that will hold the binaries.Sharing

From the Tool Box type get and drag and drop GetBuildDetail Activity, you need to put it between Update Build Number and Run on Agent.

Click on variables and declare a new variable of type IBuildDetail to hold the return value from GetBuildDetail Activity, in my case I called that variable RadwanBuildDetail.
IBuildDetail- GetBuildDetail

From properties of the GetBuildDetail Activity assign the result to to the variable that we just declared.
Assign BuildDetail variable

From the Tool Box drag and drop CopyDirectory, you must put it in Run on Agent, from the properties, select the source which is our variable and in the Destination , type the UN path for our shared folder, of course in real scenario you will not hard coded that Destination and you will make that as argument; so you can enter that by just edit the Build Definition.
CopyDirectory Activity
If you run this build the output of the drop folder will be copied to the Lab Management machine.

More information and tutorial about customizing build process

 

Upgrade TFS 2008 to TFS 2013 Update-2 step-by-step


In this post I will explain a step-by-step walk through on how to upgrade TFS2008 to TFS2013 Update-2.

Here is the flow of the walk through

Drawing2

Here are the steps:

TFS2008

Backup TFS2008 databases or just get them offline so you can copy them.

1-backup tfs 2008 database

Copy Data Files To Data Folder Or Backup Files To Backup Folder on the Data Tire for TFS2012 2-copy data files to data folder or backup files to backup folder

TFS2012

Open SQL Management Studio From Data Tire for TFS2012 3-open sql management studio from data tire of TFS

Attach Data Files or Restore Backup Files If You Made Backup.5-attach all the following databases

Attach All the Following Databases
6-we can see the attached databases as the following

Open TFS2012 Administration Console.7-open tfs 2012 administration console

Click on Configure Installed Features.
8-click on configure installed features

Choose Upgrade and then click Next.9-choose upgrade tab in tfs administration console and click start wizard10

In the Databases section, make sure you select TfsIntegration and you checked the check box to confirm you have a backup.
11-list available database for tfs

In the Account section use the default for the service account (Network Service).12-use network service as a service account13

If you installation of TFS2008 include Reporting like me, click on Configure Reporting for use with TFS.14-configure reporting to use with team foundation server

In my case I needed to choose the secure one as this what we have.15-provide the reporting services settings for team foundation server

In the Analysis Service, type the name of the machine and click Test.16

In Report Reader Account put the service account for reporting service and click Test.17-tfs reporting services reader account

If you have SharePoint click on Configure SharePoint for use with TFS.18-configure sharepoint use with team foundation server

Name the collection, I choose TFS2008_Collection.19-Enter the name of the collection

Configure the upgrade and review the success.19-2

Review your team projects in the TFS2008_Collection.20-examine the old team projects

Detach the collection.
21-tfs 2008 detach collection22-upgrade to tfs 2013

If there is any warning, review it and complete the detach process.2324

Backup The TFS2008_Collection DB.25-backup tfs2008 collection25-backup tfs2008 collection-2


Copy the backup file to the new TFS2013 Server.26-copy the collection backup to TFS 2013 DT Data tier

 

TFS2013

Open SQL Management Studio From the Data Tire for the TFS2013.27-open sql management on TFS data tier

Attach the Backup of TFS2008_Collection DB.28-attach tfs 2008 collection to tfs 201328-attach tfs 2008 collection to tfs 2013-2


Open TFS2013 Administration Console.28-2

Click Team Projects Collections and then click on Attach Collection.29-Open Team Foundation Server Administration Console

Click on List Available Databases, you should see the restored TFS2008_Collection DB, check to confirm that you have a backup of that database and click Next.30-List Available Dtabases

Name the collection, I choose TFS2008_Collection.31-Provide a Collection Name and Description

Review and then configure.32-Review the confiuration and Verify33-Attach the collection34-Monitor  the Team Project Collection attach porgress


Review the migrated team projects in the TFS2008_Collection.35-Review migrated collection and projects

Done!

For more information about versions and options for TFS upgrade

Fix Build-Deploy-Test workflow error, There are no test cases matching the criteria specified


You may face the following error while you running your Build-Deploy-Test workflow:

Exception Message: There are no test cases matching the criteria specified. Use Microsoft Test Manager to view the test cases. (type Exception)

This could happen for many reasons.

You don’t select the test suites that include your test cases, so make sure you select that, see the following image.
2014-05-26_12-42-06

You choose d the wrong configuration, so make sure you select the right configuration that match the one existing in the test plan, see the following images.
2014-05-26_12-43-00

2014-05-26_12-44-23

If you want to change the configuration for the test plan, follow the following steps:

Open your test plan, select your test suite , select all your test cases that you want to change its configuration and click on configuration
2014-05-26_12-45-00
Change the configuration

2014-05-26_12-45-32

Visual Studio 2013 Update 3 CTP 1 Available


VisualStudio2013

Microsoft released Visual Studio 2013 Update 3 CTP 1 yesterday (May 22, 2014). it’s a cumulative update that include all  new features and fixes for other previous updates so no need to install any update before that one.

There are many areas of improvements but I really liked what has been done so far for the Testing Tools.

  • You can add custom fields and custom work flows for test plans and test suites.
  • You can use Manage Test Suites permission for granting access to test suites.
  • You can track changes to test plans and test suites by using work item history.

More information about Visual Studio 2013 Update 3 CTP 1

Warning:

This update for Visual Studio and Team Foundation Server (TFS) and they are different. The Visual Studio update is an update that installs on top of whatever is already installed on the machine. The TFS update is a full layout that replaces whatever is installed on the machine. Before you try to apply the TFS update, make sure that you have a full backup of your current databases. If the TFS update installation fails, you cannot restart the update or roll back to the earlier version of TFS without performing a restore

Automated Customization for Backlog in TFS 2013


In this blog post I will share a PowerShell script that Automate a comprehensive customization for TFS 2013 Backlog.

The script perform the following tasks:

  • Export Categories.xml, ProcessConfig.xml, Bug.xml as CustomBug.xml and Feature.xml as Objective.xml
  • Rename the custom bug to be “Custom Bug” in CustomBug.xml
  • Rename the Feature to be Objective in Objective.xml
  • Change the Link Control option for the WI layout in Objective.xml to display Epic
  • Edit the Categories.xml to change the Feature category to be Epic category
  • Add the Custom Bug WI to the Requriement category
  • Create new custom category for the new Portfolio level
  • Add the Object as default work-item to this custom category
  • Clone the Portfolio section in ProcessConfig.xml
  • Change new cloned portfolio to has the new custom category
  • Rename the items in the second portfolio from Feature to be Epic
  • Added a new color section for the new WI Epic and renamed the Feature to be Objective
  • Add AssignTo column

So all you need to create new project and rename the project variable in the powershell script and run it

PowerShell for Backlog TFS 2013

……………..to continue reading, visit the complete article on the MVP blog website

http://blogs.msdn.com/b/mvpawardprogram/archive/2014/04/21/automating-visual-studio-team-foundation-server-tfs-2013-backlog.aspx

Understanding Action for state transition in Details


In this blog series I will explain TFS Process Customization in details, I will try to explain what happen behind the scene, show common errors that happen when we perform customization and answer many questions that could come for anyone perform TFS Process Customization, this series consist of following parts:

Each part consist of one or many sections as needed.

=================================================================================

Part 2 - Understanding Action for state transition in Details


Action is a very confused concept for many people, what is action? Can I create a custom action? How to use action or custom action?

So in this post I will try to simplify what is really meaning by Action and how does it work?

So the first question is: what is Action?

It’s just a unique string that used as a flag that added in the transition between states to be used by third party tools, so we can know which is the current state and which is the next state for given action in a work-item.

Just imagine that I have create a small application that has only one button that list some work-items from different types of work-items (Bug, Task, Change Request, Etc)

Change Sate based on action transation

I just want when I click on the button all work-items from Type-1 changed from Sate-1 to State-2 but if the work-items in State-2 or State-3, it remains in the same state.

I also need all work-items from Type-2 changed from Sate-2 to State-3 but if the work-items in State-1 or State-3,  it remains in the same state ……….. to do that I need to go to the WID (Work Item Definition) for these 2 types of work-items and in the transition between the desired states I will put my custom action, and this action can be retrieved by TFS SDK afterwards.

Work-item type 1

<TRANSITION from="State-1" to="State-2">

<ACTIONS>

<ACTION value="Radwan.Actions.CustomAction">

</ACTIONS>

</TRANSITION>

Work-item type 2

<TRANSITION from="State-2" to="State-3">

<ACTIONS>

<ACTION value="Radwan.Actions.CustomAction">

</ACTIONS>

</TRANSITION>

Work-item type 1
Action
Work-item type 2

Action-2
So when I get next state using TFS API or (SDK) with this custom action I can know which work-item in the desired state so I can advance it to the next state and if the work-item doesn’t has the action in the transition, that’s meaning I don’t need to advance its state.

The following code get some work-items and iterate over them and get next state for my custom action and print next state if it found that action.

WorkItemCollection witCollection = workItemStore.Query(wiqlQuery);
 foreach (WorkItem workItem in witCollection)
 {

 Console.WriteLine("Next State for {0} is {1}", workItem.Title,
 workItem.GetNextState("Radwan.Actions.CustomAction"));

 }

This will told me if my flag (Custom Action) is there or not and what is the next state so I can advance (change) the state.

class Program
 {
 static void Main(string[] args)
 {
 RetrieveWorkItems();
 Console.Read();
 }
 public static void RetrieveWorkItems()
 {
 var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new
 Uri("http://VSALM:8080/TFS/Collection"));
 var workItemStore = tfs.GetService<WorkItemStore>();

var wiqlQuery = String.Format(@"Select [State], [Title] From
 WorkItems Where [Work Item Type] = 'Task' Order By [State] Asc,
 [Changed Date] Desc"); ;

WorkItemCollection witCollection = workItemStore.Query(wiqlQuery);
 foreach (WorkItem workItem in witCollection)
 {
 Console.WriteLine("ID: {0}", workItem.Id);
 Console.WriteLine("Title: {0}", workItem.Title);
 Console.WriteLine("Next State for {0} is {1}", workItem.Title, workItem.GetNextState("Microsoft.VSTS.Actions.Checkin"));
 Console.WriteLine("Next State for {0} is {1}", workItem.Title, workItem.GetNextState("Radwan.Actions.CustomAction"));
 Console.WriteLine("");
 }
 }
 }

Automate field assignments based on State, Transition, or Reason
Work item Action list

Obtain possible next states of a work item programatically?

Changing State according to a field’s value

New State for TFS 2012

WorkItem.GetNextState Method