Archive for the ‘TFS2010’ Category

Fix TFS 2015 Build’s Queue is Empty

Today I wasn’t able to select a queue while creating a build definition or queuing a build using the new build engine that comes with TFS 2015. The drop down was blank.

This problem may occur if you don’t have build queues for your Collection or if you don’t have permission to use the queues in your build definition.

Go to the administration site for your collection

Check if you have queues for Collection

If you do, select your queueà Role à Agent Queue Users à Double click on Agent Queue Users à add users or groups

Otherwise click the “New queue” link to create a new queue


About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems. Visit us at


TFS2012: How to delete a workspace using the tf command

Today while I am writing another blog post, I encountered the following error

Exception Message: The working folder C:\Builds\5\MyTeamProject\UnitTestProject1\src is already in use by the workspace 6_5_TFS2012Build1;TFS2012BUILD1$ on computer TFS2012BUILD1. The Build Agent TFS2012Build1 – Agent1 is running as a different user Administrator and local paths can only be mapped to a single workspace. To resolve this issue, you can configure the Build Service to run as the user who owns the conflicting workspace, or you can delete the workspace using the ‘tf workspace’ command. (type WorkingFolderInUseException)

I received that error because, I changed the run as service account for the Build Controller. From a machine that has Visual Studio installed, open the VS command prompt.

Then, the first thing you want to do is check what switches TF workspace has by running the following command

tf workspace /?

To learn more about the switches or arguments, check this msdn article

You can also use the tf workspaces to target multiple workspaces or to list all workspaces for a collection

tf workspaces /collection:http://tfs2012express:8080/tfs/defaultcollection Collection:http://tfs2012express:8080/tfs/defaultcollection

The above will return you the workspaces on the current machine. If you want to view all workspaces, you need to use the /computer switch

tf workspaces /collection:http://tfs2012express:8080/tfs/defaultcollection Collection:http://tfs2012express:8080/tfs/defaultcollection /computer:*


In my case, I am using the following switches

tf workspace /delete /collection:<a href="http://tfs2012express:8080/tfs/defaultcollection 6_5_tfs2012build1;tfs2012build1$


Type Yes and press enter

Scale out Team Foundation Service Build Server

December 13, 2012 1 comment


Some Visual Studio projects hosted on (formally known as tfsPreview) require specific build environment or the installation of extra components for the build to succeed. For instance, building Windows store projects requires the build server machine to have Windows 8 operating system and Visual Studio to be installed, building a BizTalk project requires the BizTalk SDK to be installed on the build servers, building Lightswitch applications with extensions requires Visual Studio and the extensions to be installed on the build servers and the list goes on.

In this article, I will setup an on premise Build Server to build Windows Store applications that are hosted in This article assumes you already have an account with and already have a physical machine or VM with Windows 8 as an operating system and Visual Studio 2012 Express for Windows 8 or higher.


In this article, I have a Windows Store application named “MyWindowsStoreApplication” which is checked in to Building the MyWindowsStoreApplication using the “Hosted Build Controller” and agent will fail to build as shown in the following figure


The TFS Build fails with the error indicating that Windows 8 operating system is required to package the built Windows Store application.


The solution for the problem is to scale out TFS Server’s Build capabilities and host a TFS Build Controller and Build Agent on a computer or VM that has Windows 8 as an operating system.


The system requirements to build Windows Store applications are:

  • Windows 8 Operating System
  • Visual Studio 2012 for Windows 8 or higher

Installing TFS Controller and Build Agents

In the following section we will go through the steps needed to create a TFS Build Controller and Build Agents on a local server for the source code repository.


The assumption is that you already have a physical machine or VM that has a Windows 8 operating system and Visual Studio 2012 installed.

The following are the step by step instructions to scale out build server:

  • Insert the TFS2012 DVD or extract the iso file
  • Execute tfs_server.exe on the root folder, if you are using TFS Express, you need to execute tfs_express.exe


  • Accept the license terms for Team Foundation Server
  • Click the Install Now button


  • When the installation is complete, the Team Foundation Server Configuration Center is launched
  • Select the Configure Team Foundation Build Service from the list
  • Click the Start Wizard button


  • Click Next in the Build Service Configuration Wizard to move from the Welcome screen to the Project Collection screen


  • Click on the Browse button on the Project Collection screen
  • Click the Servers button on the Connect to Team Project Collection dialog
  • Click the Add button on the Add/Remove Team Foundation Server Dialog
  • Type the name or URL of your team foundation server and select the HTTPS protocol
  • Click the OK button


  • Once the OK button is clicked, the Sign in to Team Foundation Server window will be launched
  • Enter your email address and password
  • Click the Sign in button


  • Your Team Foundation Server should show up in the Connect to Team Project Collection dialog
  • Click the Connect button


  • Now we are back to the Build Service Configuration Wizard, in my case, I haven’t configured on premise TFS build controllers or agent before. Hence, I am getting the Found 0 build controllers and 0 build agents message
  • Click the next button image
  • On the Build Services screen, select Use the default setting. For illustration purposes, I kept the number of build agents to 2. The number of build agents allows to run multiple builds concurrently
  • Click the Next button


  • On the Settings screen, the default option is Use a system account option is selected. The Local Service account is selected by default if the machine is not part of a domain. Network Service account is selected by default if the machine is part of a domain
  • Click the Next button


Review the settings and click the Verify button to verify the settings


Click the Configure button


If the configuration is complete successfully, click on the Next button and then close the Team Foundation Build Service Configuration window



  • Back at the Team Foundation Server Configuration Center, you should see a green check mark which indicates that the service is configured
  • Close the dialog if you don’t want to configure other sections


  • Open the Team Foundation Server Administration Console
  • Click on the Build Configuration node
  • Notice that the controller and the Agents are in a healthy state and enabled (green icon). A red error icon would show up instead in the case the controller or the agents are disabled


Modify Build Definition

  • Open Visual Studio on your development machine
  • Open Team Explorer window
  • Click on the Build link


  • Right click on the build definition that builds your Windows Store application
  • Click on Edit Build Definition


  • Click on the Build Defaults tab
  • From the Build controller combo box select the build controller created in the previous section


  • Click Save
  • On the Team Explorer window, right click on the build definition
  • Click on Queue New Build


  • The build should pass if you don’t have any build errors


Team Explorer: Save Codeplex Username and Password

A friend of mine emailed me few minutes ago saying that it is too annoying that TFS keeps asking him to enter his username and password and asked me if there is a way to save the username and password. The following are the steps to do so:


Using Windows 7:

Open Windows Explorer and go to Control Panel\User Accounts and Family Safety\Credential Manager

Click Add a Windows Credential



Enter in the “Internet or network address” textbox

Enter your username and password. To find out your username check this Post


TFS2010 Add New Argument/Parameter to a Build Template

This post was created in response to this forum question on msdn:

It is fairly simple to add a new argument to your build template

Click on the Arguments tab

Scroll all the way down and click “Create Argument”

Type the name of your argument (e.g. BuildEnvironment)

To make the argument required, to customize its category, or use a customized editor, we need to create a new parameter in Metadata property as shown in the following image

In the team definition, I added Switch activity (can be added where you want to use that argument) and changed the expression to BuildEnvironment.ToLower to make it case insensitive. Switch activity can be replaced with If activity if the argument can be set to only two values

Click on “Add new case”, type case value to be “dev” or whatever value you need.

Repeat the above steps for other environments (i.e. QA, Prod,..etc)

Click “Add an activity” next to the case statement (e.g. dev)

Drop an activity where it says “Drop activity here”, you can use an Assign activity from the primitive group to initialize certain path

When done, check in the template

Create a new build definition

Under the Process tab, choose your customized template

Notice that you can see your new argument as a parameter

Categories: Team Build, TFS, TFS2010 Tags: , ,

TFS2010: Retrieve Associated Workitems to Changesets TFS API

How to Retrieve Workitems Associated to Changesets in TFS using C# and

You need to add the following references




They are located at “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\” on my Windows 7 instance

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace ConsoleApplication2
    class Program
        static void Main(string[] args)
            var changeset = GetChangeset(new Uri("http://win7-pc:8080/tfs/defaultcollection"), 21);
            foreach (var w in changeset.WorkItems)
                Console.WriteLine("WorkItemId:" + w.Id);
                Console.WriteLine("WorkItemTitle:" + w.Title);


        private static Changeset GetChangeset(Uri serverUri, int changesetId)
            var tfs = new TfsTeamProjectCollection(serverUri);
            var svc = tfs.GetService<VersionControlServer>();
            var changeset = svc.GetChangeset(changesetId);

            return changeset;


Imports Microsoft.TeamFoundation.VersionControl.Client
Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Module Module1

    Sub Main()

        Dim changeset As Changeset = GetChangeset(New Uri("http://win7-pc:8080/tfs/defaultcollection"), 21)
        For Each w As WorkItem In changeset.WorkItems
            Console.WriteLine("WorkItemId:" & w.Id)
            Console.WriteLine("WorkItemTitle:" & w.Title)


    End Sub

    Function GetChangeset(ByVal serverUri As Uri, ByVal changesetId As Integer) As Changeset
        Dim tfs As TfsTeamProjectCollection = New TfsTeamProjectCollection(serverUri)
        Dim svc = tfs.GetService(Of VersionControlServer)()
        Dim changeset As Changeset = svc.GetChangeset(changesetId)

        Return changeset
    End Function
End Module

Categories: .NET, C#, TFS, TFS2010, VB Tags: , , ,

Customize Binaries Folder in TFS Team Build Part-2

In this post I will go through a different way to accomplish what I posted in Part-1. Actually this approach is way simpler and less error prone than the first one.

I will create a new configuration named TFS, change the output path for each project for that configuration to  SolutionPath\bin\Projectname, Create a team build project and update Team build template.

Create a New Configuration

We want to create a new configuration for TFS team build and we don’t want to change the Release or Debug configurations. To do so

  • Right click on the solution
  • Click configuration manager menu

  • From the “Active solution configuration” drop down select <New…>

  • Type TFS in the name textbox
  • Select the configuration to copy configuration from (e.g. Release, or debug)
  • Click OK

  • In the Solution configuration, I am changing the Active Solution Platform to Mixed Platform because the projects in the solutions are targeting different platforms

  • Click Close

Preparing the Projects in the Solution

The following steps will change the output path from bin folder to SolutionPath\bin. I my solution I had a webApplication and a windowsApplication

  • Make sure that the TFS Configuration is selected
  • Change the Output location for each project on the solution to ..\bin\ProjectName.
    • Right click on the projectà properties
    • Click the build tab
    • Fill the “output path” textbox with ..\bin\ProjectName

  • Build the solution to make sure it is working

  • Check in the solution

Create a new Team Build

  • Open Team Explorer
  • Right click on the Builds node
  • Create a new Build, I named it CustomizeBinariesFolder
  • In the Process Tab
  • Expand Items to build
  • Select the solution we configured above
  • Expand Items to build
  • Click the ellipsis next Configurations to Build

  • Type TFS under Configuration and the Platform of that configuration
  • Fill the other fields as you want

Create new Team Build Template

  • Edit your Team Build Definition
  • Go to the process tab
  • Under Build Process Template click the New… button
  • Select an existing template that you want to copy, I am selecting the DefaultTemplate
  • Name the new File
  • Click OK

  • Save the definition
  • Open Source Control from Team Explorer
  • Get latest from BuildProcessTemplates

  • Open CustomizeFolderTemplate.xaml
  • Find “Run MSBuild for Project” Activity under “Try to Compile the Project” block.
  • Clear the OutDir property

  • OutDir property over writes the default output path on each project. By Clearing the OutDir property for the MsBuild Activity, Team build will use the Output Path defined in the project. In my case, C:\Builds\{AgentNumber}\Lajak\CustomizedBinariesFolder\Sources\WindowsFormsApplication1\bin
  • Now we want to copy the contents of the bin folder from the above path (i.e. solutionPath\bin) to the binaries folder
  • Add Copy Directory Activity under Run MsBuild for Project

  • Change the Source Property to IO.Path.Combine(IO.Path.GetDirectoryName(localProject), “bin”), which means, Path of solution file + “\” + bin. By using the combine method we don’t have to worry about the Locale of the machine
  • Change the Destination property to BinariesDirectory
  • Save the Template
  • Go to Source Control Explorer and Check in the Template
  • Run the Team build definition that uses the template you have just modified. I am building the CustomizedBinariesFolder Definition