TFS 2012 – Customize Backlog Pages

September 12, 2012 Leave a comment


Add New Field for Backlogs

Download agile process config file

witadmin exportagileprocessconfig /collection:http://tfsbox:8080/tfs/FirstCollection /p:CMMI-Test /f:"d:\tfs2012\AgileConfiguration.xml"

New Field To Add Dialog

Locate the AddPanel element and Iteration Path Element :



        <Field refname="System.Title" />

        <Field refname="Microsoft.VSTS.CMMI.RequirementType" />

        <Field refname="System.IterationPath" />



Upload config file to TFS Server

witadmin importagileprocessconfig /collection:http://tfsbox:8080/tfs/FirstCollection /p:CMMI-Test /f:"d:\tfs2012\AgileConfiguration.xml"


Notice that Iteration Path Field appeared in the Add Dialog



witadmin command-line tool can be found in below locations
cd %programfiles%\Microsoft Visual Studio 11.0\Common7\IDE

Note: For Windows 64-bit version…replace %programfiles% with %programfiles(x86)%

Add Work Item type as Backlog Item

By Default only Work items in “Requirements” category (defined in Collection Categories) can be added as Backlog item. If you want to add other workitems such as Bugs, Change Requests as Backlog Item…Here is the solution.

Download Categories

witadmin exportcategories /collection:http://tfsbox:8080/tfs/FirstCollection /p:CMMI-Test /f:"d:\tfs2012\categories.xml"

Add New WorkItems

Locate the CATEGORY element for the "Requirement Category" in categories.xml. By default (in CMMI process template) it has only one child for Requirement Workitem. Add Other workitems to the list. In the below code, I added Bug, Change Request, Task workitems.

<CATEGORY refname="Microsoft.RequirementCategory" name="Requirement Category">

  <DEFAULTWORKITEMTYPE name="Requirement" />

  <WORKITEMTYPE name="Bug" />

  <WORKITEMTYPE name="Task" />

  <WORKITEMTYPE name="Change Request" />


Upload Categories

witadmin importcategories /collection:http://tfsbox:8080/tfs/FirstCollection /p:CMMI-Test /f:"d:\tfs2012\categories.xml"


TF400916: The current configuration is not valid for this feature. This feature cannot be used until a Team Foundation Administrator corrects the configuration.


Add Microsoft.VSTS.Scheduling.Size and Microsoft.VSTS.Common.StackRank field to Change Request work item type of the team project.

Now you can add Change requests as Backlog



In the same way you can add “Issue”, “Bugs” work item type as well. But what about Tasks?

By Default Task work item is in “Task Category” and you can’t have an work item in both “Task category” and “Requirement category”. Also Backlogs are only for “Requirement category”

Hope this Helps…!

Categories: Uncategorized

Configuration Transformation in Windows/Console Apps

August 31, 2012 Leave a comment


If you are an ASP.NET Web Developer you might have seen the advantages of Web.Config Transformations. Here you can have separate Config files for each configuration defined in “Application Configuration Manager”

image image

But the Configuration Transformations are not supported for Windows Or Console Applications. But there is an work-around way to get it done. Lets see How it is…by Step by Step.



You can observe that this has only one App.Config file. Lets add two configuration files “App.Test.Config”, “App.Prob.Config”


Newly added files are at the Root Level of the Project instead of under App.Config file. See how they are defined in .proj file. (For this you need unload the project and Edit the Project File in Visual Studio)


Use DependentUpon  element to make “App.Test.Config”, “App.Prob.Config” files Childs to “App.Config” as  shows below…


Reload the Project and See the result


Let Add a connection String to the App.Config file.

<?xml version="1.0"?>



        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>




    <add name="MyConnString" connectionString="Data Source=.;Initial Catalog=MyDataBase_dev;Integrated Security=True" providerName="System.Data.SqlClient" />




Add Connection strings to Child Config files also… (with the change in database name MyDataBase_Prod, MyDataBase_Test)

<?xml version="1.0" encoding="utf-8" ?>

<configuration xmlns:xdt="">


  <connectionStrings xdt:Transform="Replace">

    <add name="MyConnString" connectionString="Data Source=.;Initial Catalog=MyDataBase_Prod;Integrated Security=True" providerName="System.Data.SqlClient" />




To know more about the Transformation syntax refer below links

Now…Let Test it by Setting The Project Configuration to Test and Build…


If you look at the config file at bin\Test folder…you will find connection string same as “App.config” file.


Out of the box, .config file transformation is only available for Web application projects in Visual Studio 2010. Console, WinForms, WPF and other applications projects don’t support this capability out of the box.

What is the Work-Around? TransformXml Task

In this MSBuild code snippet, we are using the TransformXml task defined in the Microsoft.Web.Publishing.Tasks.dll. This is the task responsible for transforming Web.config files in Web application projects. It takes parameters that specify names of the original .config file, the transform file and the output (transformed) file. We use TransformXml task to override AfterCompile target if a transform file exist for the current build configuration. For example, if our project contains a file called App.Debug.config and the current project configuration is Debug, the AfterCompile target will be called. Finally, we use ItemGroup element to change the built-in AppConfigWithTargetPath item collection.

Add Below code to the Project file.

  <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />

  <Target Name="AfterCompile" Condition="exists(‘app.$(Configuration).config’)">

    <TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />


      <AppConfigWithTargetPath Remove="app.config" />

      <AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">





That’s it….!

Build the project in Test Configurations and see the output @ bin\Test folder…!

Hope this Helps..Smile

Categories: Uncategorized

Excel – Highlight Row & Columns of Currently selected cell

February 29, 2012 Leave a comment


In large worksheets it is very difficult to track the current row and column of the currently selected cell.


Found a nice solution here

Dim RowRng As Long
Dim ColRng As Long

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

    If RowRng <> 0 Then
        With Rows(RowRng).Interior    ‘begin clearing previous highlights
            .Pattern = xlNone
        End With
        With Columns(ColRng).Interior
            .Pattern = xlNone
        End With
    End If
    RowRng = Target.Row
    ColRng = Target.Column
    With Rows(RowRng).Interior       ‘set highlights
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 49407
    End With
    With Columns(ColRng).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 49407
    End With
End Sub

This works as expected. Sample screen is shown below…


Categories: Office

TFS 2010 Build Automation–Different Folders for each VS Project

January 30, 2012 Leave a comment


My Visual Studio solution contains several projects of different kind (Web Apps, Console Apps, etc.). If you are using single TFS Build definition for all projects, then TFS will place all projects output files into the root of Drop folder. It is very hard to manage the output files.

It would be if TFS placed output files of each project in a separate folder. TFS 2010 don’t have this feature  by default, but there is an workaround with two steps.


1.1 Select “Run MsBuild for Project” activity from TFS Build Template Workflow.


1.2 Update CommandLineArguments with the following
String.Format("/p:SkipInvalidConfigurations=true /p:TeamBuildOutDir=""{0}"" {1}", BinariesDirectory, MSBuildArguments)

1.3 Clear OutDir property.


Update PropertyGroup > Ouputpath in all Project files (.csproj / .vbprog) in the Visual Studio Solution, for each configuration.

<OutputPath Condition=" ‘$(TeamBuildOutDir)’==” ">bin\Debug\</OutputPath>
<OutputPath Condition=" ‘$(TeamBuildOUtDir)’!=” ">$(TeamBuildOutDir)\WebApplication3\</OutputPath>

That’s it. Hope it helps.

Categories: TFS

Query dbproj file to get list of database object

October 3, 2011 Leave a comment

Recently I got a requirement to parse database project to list down all procedures and tables etc.

I binged net for the solution and able to get the query finally.

SELECT @xml = CAST(xmlFile.BulkColumn AS XML)
FROM OPENROWSET(BULK 'D:\WorkArea\Projects\myDatabaseProject.dbproj' ,single_blob) AS xmlFile
IF OBJECT_ID('tempdb..#t') IS NOT NULL
drop table #t

build.value(‘@Include’,’nvarchar(1000)’) AS _path
into #t
FROM @xml.nodes(‘//ns:Build’) AS R(build)
IF OBJECT_ID(‘tempdb..#Result’) IS NOT NULL
drop table #Result
CREATE table #Result(fname varchar(1000), ftype varchar(100))
— Get Indexes
INSERT INTO #Result (fname, ftype)
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘index’ from #t WHERE _path LIKE ‘%.index.sql’
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘proc’ from #t WHERE _path LIKE ‘%.proc.sql’
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘table’ from #t WHERE _path LIKE ‘%.table.sql’
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘function’ from #t WHERE _path LIKE ‘%.function.sql’
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘view’ from #t WHERE _path LIKE ‘%.view.sql’
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘defconst’ from #t WHERE _path LIKE ‘%.defconst.sql’
SELECT reverse(left(reverse(_path), charindex(‘\’, reverse(_path)) -1)) as _name, ‘schema’ from #t WHERE _path LIKE ‘%.schema.sql’

select * from #Result where ftype = ‘table’

Similarly we can parse SSIS projects also. Script is as shown below.

SELECT @xml = CAST(xmlFile.BulkColumn AS XML)
FROM OPENROWSET(BULK 'D:\WorkArea\MySSISProject.dtproj' ,single_blob) AS xmlFile
IF OBJECT_ID('tempdb..#t') IS NOT NULL
drop table #t
Select'Name[1]','nvarchar(1000)') AS _path
FROM @xml.nodes('//Project/DTSPackages/DtsPackage') AS R(build)


Categories: Uncategorized Tags: ,

Rollback Changeset in TFS 2010

July 15, 2011 Leave a comment

Recently, I got a requirement to rollback changeset from TFS 2010. I referred some articles in the net. Below are some of them

Here I want to summarize the steps to rollback change sets in TFS 2010.

As described in above links, TF is a TFS command line tool available in “C:\ProgramFiles\Microsoft Visual Studio 10.0\Common7\IDE”. There are several arguments we pass to it. Among them /Changeset and /toVersion are mostly used arguments.

Syntax: tf rollback /changeset:C<n> <TFS BranchPath> /r — where <n> is the changeset number
How it works?: Removes the changes done as part of the <n> changeset.


Syntax: tf rollback /toVersion:C<n> <TFS Branch Path> /r –where <n> is the changeset number
How it works?: This will remove the changes done by all changesets after thespecified changeset.

For example, if you have change sets 1, 2, 3, 4. The command “tf rollback/changeset:C4” will remove the changes of Changeset 4. The command
“tf rollback /toVersion:C2” will remove the changes of Changesets 3,4 and leaves the at change set#2.

Points to remember:

  1. TFS Branch Path should
    be path to the branch ex: $/project/applicaitonFolder/branchFolder
  2. You need to run this TF command from the workspace folder.
  3. Open VS 2010 command prompt
  4. Go to the branch folder in your local disk
    Ex: D:\project\applicaitonFolder\branchFolder>tf rollback /toVersion:C123
    $/project/applicaitonFolder/branchFolder /r

On successful execution of TF Rollback, files will be checked-out in your workspace. You can check-in them to complete the rollback.


Categories: Uncategorized

TFS – Get Compare Results

January 25, 2011 Leave a comment

I need to export the Folder compare results to a text file. Command used for this is “tf folderdiff

Note: This command comes with VS2008, you can’t found in VS2005.
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE>tf folderdiff /?
TF – Team Foundation Version Control Tool
Copyright (c) Microsoft Corporation.  All rights reserved.

Displays a visual representation of the differences between files in two server
folders, in a server folder and a local folder, or in two local folders.

tf folderdiff [sourcePath] targetPath [/recursive] [/noprompt]
              [/server:serverName:port] [/filter:filter]

tf folderdiff $/Project/MyApplication/Branch1/database $/Project/MyApplication/Branch2/database /login:myDomain\userName,myPassword /s:http://myTfsServer::8080 /view:different,sourceOnly,targetOnly /noprompt  /recursive > c:\result.txt

Very useful command.

Categories: Uncategorized