tf.exe (Team Explorer) vs. tf.exe (Team Explorer Everywhere)

I recently had an interesting experiencing writing post build PowerShell script for a client. The client wanted to check in certain files into source control after the build is finished. Sounds easy, right? You can use either good old tf.exe command line utility from Visual Studio command tools. Or, you can use something more current like PowerShell to write a simple script that will check in pending changes for you. The problem is that the client also wanted to associate work items with the check in. Not a big deal, right? Well, apparently it is a big deal. You cannot associate work item with the check in using tf.exe command tool. And, what's even stranger, I could not find a way to associate work item with the check in using PowerShell. I got stuck with figuring out how to make WorkItemCheckinInfo[] parameter in Workspace.Checkin method to work properly.

This is how I learned that apparently you can associate work item with TFS check in, but you have to use tf.exe command from Team Explorer Everywhere. Apparently, even though the names are the same, those are very different command line utilities. When you use tf.exe from Team Explorer Everywhere, you can associate work item with the check in using a simple command:

tf checkin ItemSpec -associate:WorkItemIds

It's that easy. I just wish –associate option was available in common tf.exe command from Visual Studio command tools. I would also wish that those two seemingly identical tf.exe commands would actually do the same thing (the same way), or at least that those commands would have different names to avoid the confusion. By the way, there are also other differences between those two commands with the same names. You can get them form the links provided in the post. I'm too upset to list myself L

Ways to learn how to develop Windows 10 applications

Here is a bunch of links to resources that will help you get up to speed on what's new for developing Windows 10 applications.

Want to download Visual Studio SKU's including VS 2015 click here

Everything you needed to know to write applications using MS Tools

    Windows 10 and what's new

    Get Started

    Design

    Develop

    Publish

Want to take Microsoft Virtual Academy (MVA) Windows 10 Courses click here

Channel 9 has some great windows 10 related videos here

 

Toronto Enterprise DevOps User Group

I have started a new user group with the focus on Enterprise DevOps. DevOps is getting significant attention in the industry. Many organizations don't understand what DevOps is, how to adopt DevOps practices effectively within the organization, and are not aware of what DevOps tools to use. Toronto Enterprise DevOps User Group is focused on applying DevOps practices in the enterprise environment. This group is for people in the Greater Toronto Area who are interested in continuous deployment/integration, release management, infrastructure as code, change/configuration management, load testing & auto-scale, performance/availability monitoring, capacity management, automated testing, automated environment provisioning/de-provisioning, self service environments, automated recovery (rollback & roll-Forward), and many more of constantly evolving DevOps practices. Every level of experience is welcome, all we ask is that you come with an open mind and are excited to share your knowledge.

The first meeting is on September 10th, 2015. We'll start with a discussion of What is DevOps? DevOps is a term for a group of concepts that, while not all new, has catalyzed into a movement and is rapidly spreading throughout the technical community. Like any new and popular term, people have somewhat confused and sometimes contradictory impressions of what it is. Is it "Quality" or "Agile,"? Well, DevOps is a large enough concept that it requires some nuance to fully understand. DevOps is the practice of operations and development engineers participating together in the entire service lifecycle, from design through to the development process to production support. We will cover what DevOps is and is not during our first user group meeting.

Visit our website for more info. See you there.

Teaching Students how to program with Python @ Synergy

Next week I will be going back to school. Well sort of.

I am going to teach a one day seminar on programming to students grades 6-12 at Synergy.

Synergy is a summer experience program offered by the DeGroote School of Business at McMaster University for students in grades 5 -12.  It affords students the opportunity to experience business as a field of study in a post-secondary setting.

I'm teaching the class using Python and Visual Studio.

Should be a lot of fun.

OpsHub Visual Studio Online Migration Utility

I recently got to use OpsHub Visual Studio Online Migration Utility to help the client move from on premises TFS environment into the awesomeness of Visual Studio Online. OpsHub Visual Studio Online Migration Utility is actually pretty good and solid tool. The migration was very smooth and relatively painless. I thought I share some of the things I have come across when using VSO using OpsHub Visual Studio Online Migration Utility:

  • OpsHub Visual Studio Online Migration Utility is free and can be downloaded from Visual Studio Gallery here (http://aka.ms/OpsHubVSOMigrationUtility)
  • OpsHub Visual Studio Online Migration Utility can only be installed on 64 bit Windows machine
  • During the installation, you will be required to fill out the registration info. Please make sure that you have provided a valid email address since you will need a verification code to proceed with the installation that will be sent to the email address you provide during the install. Usually, it takes a couple of minutes for an email to come through. Check your Spam folder in case if the email was mislabeled by your spam filter
  • If you are using proxy servers to connect to the internet, you will need to do the following http://opshub.com/main/index.php/ovsomu-proxy to get the installer working. Please note that even if you follow the instructions, and even if you get passed the registration page to next page (Verify Email page), which to a normal person mean that the registration process was successful and that you should receive verification email, it does not necessarily mean that you will get an email. The reason for it could be that your proxy is blocking the installation wizard from sending the registration info to Opshub. Very frustrating. As a workaround, you can run the installation wizard on any other machine that is not going through the proxy, fill out the registration email, wait for an email, then use the verification code that you have received to install OpsHub Visual Studio Online Migration Utility on any other machine in your network. From what I can tell, verification code is not tied to machine that you're installing on in any way
  • If you have installed OpsHub Visual Studio Online Migration Utility while your machine was going through the proxy to get to the internet, and then managed to convinced your IT to allow you to bypass proxy, you will need to uninstall OpsHub Visual Studio Online Migration Utility, remove any changes you've made as per http://opshub.com/main/index.php/ovsomu-proxy and then reinstall OpsHub Visual Studio Online Migration Utility. Sounds silly, but it's true. By the way, I strongly recommend that you spent some time and convince your IT to allow the machine that is running OpsHub Visual Studio Online Migration Utility to bypass the proxy, it just makes things a lot easier. Especially when you start configuring the migrations.
  • Before you start configuring migrations, you will need to:
    • Pre-create empty team projects (with matching process templates) for the team projects that you will be migrating from on premises TFS
    • Add users to your Visual Studio Online account and grant them some permissions on the team projects. One of the steps in configuring the migrations is map local users to VSO users, so you'll need users to be in place before you start the migration
    • Add VSO account that you will be using to migrate to Project Collection Service Accounts group in VSO
  • Remember that you can migrate one project a time. You don't have to move the entire project collection from on premises to VSO
  • If you're migrating work items then you might have to deal with template discrepancies. Be patient.
  • OpsHub Visual Studio Online Migration Utility is provided by a company called OpsHub, Microsoft partner. Their support is pretty good. You can reach them via email ovsmy@opshub.com or via StackOverflow using hashtags #opshub and #visual-studio-online. Please keep in mind that the company is located in California, USA, and take into account the time difference when awaiting a response.

That's all.

Schedule TFS releases

I have been asked if TFS 2013 Release Management allows you to schedule TFS releases. Yes, you can schedule TFS release. What I mean is TFS allows you to schedule the deployment time of the release during the acceptance step of the release path. It's that easy.

But what if you want to schedule release to happen on a regular basis, for example you would like to automatically deploy/release the latest code to the development environment every Monday/Wednesday/Friday nights. TFS 2013 Release Management does not really have that feature. Luckily, we have reach TFS API and PowerShell. So, here is a PowerShell script that triggers release of the last successful build with the build quality set to "Ready for Deployment" (obviously, you can use any other filter to get the build you want):

param

(

    [string] $tfsCollectionPath = "http://SERVERNAME:8080/tfs/COLLECTIONNAME",

    [string] $tfsProjectName = "PROJECTNAME",

    [string] $buildDefinitionName = "BUILDDEFINITIONNAME",

    [string] $releaseTemplate = "RELEASETEMPLATENAME"

)

 

# Clear Output Pane

clear

 

# Enforce coding rules

Set-StrictMode -version 2.0

 

# Loads Windows PowerShell snap-in if not already loaded

if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )

{

    Add-PSSnapin Microsoft.TeamFoundation.PowerShell

}

 

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Common")  

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")  

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Common")  

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")  

 

[Microsoft.TeamFoundation.Client.TfsTeamProjectCollection] $tfs = get-tfsserver $tfsCollectionPath

 

$tfsCollection = New-Object -TypeName Microsoft.TeamFoundation.Client.TfsTeamProjectCollection -ArgumentList $tfsCollectionPath

 

$server = new-object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection(New-Object Uri($tfsCollectionPath))

$buildServer = $server.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])

$buildDetail = $buildServer.QueryBuilds($tfsProjectName, $buildDefinitionName)

 

$foundBuilds = $buildDetail | where {($_.Quality -eq "Ready for Deployment") -and ($_.Status -eq "Succeeded")} #| sort $_.BuildNumber

 

if ($foundBuilds -eq $null) 

{

    Write-Host "No builds found"

}

else

{

#$foundBuilds = $build | select BuildNumber, SourceGetVersion, Quality, DropLocation

 

    $LastReadyForDeploymentBuildNumber = $foundBuilds[-1].BuildNumber

    $LastReadyForDeploymentBuildDropLocation = $foundBuilds[-1].DropLocation

    Write-Host "Triggering build " $LastReadyForDeploymentBuild

 

    &"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Release Management\bin\ReleaseManagementBuild.exe" release -rt $releaseTemplate -pl $LastReadyForDeploymentBuildDropLocation

}

 

As you can see from the script, script first connects to TFS, finds the proper build definition, then looks for last successful and "Ready for Deployment" build, then uses ReleaseManagementBuild.exe to trigger the release for that build. Obviously, the script could be improved, for example, to include the exception handling, but it should enough to get you started.

Now that you have the script, you can use Windows Task Scheduler to trigger the release outside of the Release Management client. As often as you need it, whenever you feel like it.

TFS/Visual Studio Online API

As I was looking for API reference for TFS Release Management, I came across this useful link that I wanted to pass along. Visual Studio Online REST API Reference page (https://www.visualstudio.com/en-us/integrate/api/overview) includes API reference for TFS components like build, work item tracking, version control/GIT, load test, test management, shared services, etc. Basically, it includes reference for all existing API hooks for TFS/VSO.

I have also found this blog post (http://blogs.msdn.com/b/aseemb/archive/2014/12/23/how-to-program-against-release-management.aspx), which includes the API reference for TFS release management. It includes sample code that allows you to create a user, environment, release path, release definition, etc. Please note that release management (like build) is changing quite a bit in TFS 2015, so it's safe to assume that the API for build and release management will also be changing. Visual Studio Online REST API Reference page should have the latest changes, so just use it as a reference :)

If you haven't already seen it, look at the information on getting started with these APIs.

Gartner’s Public Cloud Storage Services

 

Microsoft Named a Leader in Gartner's Public Cloud Storage Services for Second Consecutive Year

Check out the details in Nicole Herskowitz's Blog.

VS 2015 Goes RTM!

 

 

You are invited to join an online event on July 20th to learn about the new features and technologies coming with this release. No registration is required! Just follow the link and save the date on your calendar! There will be live Q&A session with the VS developers involved in building the app after the pre-recorded show video. 

   

Visual Studio Release Event

   

 

For more details about Visual Studio 2015, check out the VS 2015 feature topics available here.

PowerShell & TFS

There have been occasions where I've wanted to create work items in bulk.

For example: Every time you create a User Story your team has several standard Tasks that need to be created. Write Test Cases, Execute test cases, Deploy to QA, etc. I don't want to manually go through dozens or work items adding the same set of work items as children to each one over and over.

Excel is a pretty good option, certainly faster than doing it one at a time via Team Explorer or the Web interface. In the past I have written C# applications to do this through the TFS API. This works great and is very easy to code.

I am always trying to force myself to get better with PowerShell, so I started searching for examples of calling the TFS API from PowerShell. This helped me piece together the parts I needed to solve this problem with PowerShell.

These were my requirements:

  • There are N Stories in TFS each one represents an existing report that needs to go through several stages of work.
  • We want 6 new Stories created as children of each Report Story so the work can be assigned to different teams in the organization then the individual teams can create their own tasks.
  • We don't want the Child Stories to all have the same title. That is fine when you see them in context of their parent like this:
    • Report 1
      • Report Attributes
      • Data Lineage
      • Gap Analysis
    • Report 2
      • Report Attributes
      • Data Lineage
      • Gap Analysis
  • However when you see the Report Attributes Story on its own it means very little.
  • Therefore I want was something like this:
    • Report 1
      • Report Attributes for Report 1
      • Data Lineage for Report 1
      • Gap Analysis for Report 1
    • Report 2
      • Report Attributes for Report 2
      • Data Lineage for Report 2
      • Gap Analysis for Report 2
  • Plus each sub story needs to have the same Area, Team and other attributes as its Parent Story

As you can see a simple cut and paste in Excel won't do, because I would still have to edit each work item to add the report name to the title and populate the fields from the parent that I want brought over.

PowerShell to the rescue

if ( (Get-PSSnapin -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null )

{ Add-PSSnapin Microsoft.TeamFoundation.PowerShell }

 

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Common")

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.WorkItemTracking.Client")

 

#Get the TFS Collection

$tfsCollectionUrl = "http://Server:8080/tfs/CollectionName"

$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($tfsCollectionUrl)

 

#Get the WorkItemStore Service

$ws = $teamProjectCollection.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")

 

#Get the Team Project

$proj = $ws.Projects["Team Project"]

 

Write-Host "Team Project Collection: "$teamProjectCollection

Write-Host "Project:" $proj.Name

Write-Host "---------------------"

 

#Write a query to get the parent work items

$ParentWorkItems = $ws.Query("SELECT [System.Id] FROM WorkItems WHERE [System.AssignedTo] = 'Dave Lloyd' ")

 

#the Sub Stories you want to create as Children

$ChildStoryTitles = @( "Report Attributes","Data Lineage","Gap Analysis","Impact Analysis","Remediation","Testing")

 

#For each Parent Work item

foreach ($WorkItemParent in $ParentWorkItems)

{

$counter=1

Write-Host "Parent workItem:" $WorkItemParent.ID "-" $WorkItemParent.Title

 

#For each Parent create 6 New User Stories

foreach ($childTitle in $ChildStoryTitles)

{

$story = $proj.WorkItemTypes["User Story"]

$workitemChild = $story.NewWorkItem()

#Append the Parent Title to the end of the Child Title

     #System fields like title can be referenced directly and show up in intelliSence

$workItemChild.Title = $childTitle + " for " + $WorkItemParent.Title

#There is an order so I used a counter to set the Stack Rank on the CHild Stories

#For non-system fields use the fields member the name of the field and the value property

$workItemChild.Fields["Stack Rank"].value = $counter

#take any fields from the parent that you want to bring down into the child

$workItemChild.AreaId = $WorkItemParent.AreaId

$workItemChild.Save()

 

Write-Host " Child workItem" $workitemChild.ID $WorkItemChild.Title

 

#Link the CHild work item to the Parent Work item

$linkType = $ws.WorkItemLinkTypes[[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreLinkTypeReferenceNames]::Hierarchy]

$link = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLink($linkType.ReverseEnd, $workitemParent.ID)

$workitemChild.Links.Add($link)

$workItemChild.Save()

$counter++

}

 

}