Well, it's been a long time since I have had the time (okay made the time) to blog on something interesting. To make up for that, I have a quick entry that includes all kinds of interesting tidbits.
This entry is based on Team Build's next version which is available in a CTP release right now, and will be in Beta very soon (don't ask, I don't know when). In the next version of Team Build, we have included an Object Model (OM) that wraps all the functionality of the Web Services. This makes writing your own apps that need build information, much easier.
As I talk about how to use the methods and objects in the OM, I will show examples using PowerShell commands. PowerShell is an incredible recently new shell for Windows, that allows you to manipulate not just text output by command line apps, but real objects returned from any managed library. If you want to know more (and you should), goto to http://www.microsoft.com/PowerShell
So, here's a quick example:
Problem: What Build Definitions are building this C Sharp project?
You can't find this out in Visual Studio without looking at every Build Definition's workspace mappings. But there's a simple OM call that can do the work for you - GetAffectedBuildDefinitions. All you have to do is
- Get a TeamFoundationServer object.
- Get the IBuildServer from the TFS object.
- Create a string array that contains the server path to the project file.
- Pass that string array to the GetAffectedBuildDefinitions method of IBuildServer.
Here's the PowerShell commands...
Copyright (C) 2006 Microsoft Corporation. All rights reserved.
PS C:\> [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
PS C:\> [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
PS C:\> $serverName="http://server:8080/"
PS C:\> $tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($serverName)
PS C:\> $buildserver = $tfs.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
PS C:\> $defs = $buildserver.GetAffectedBuildDefinitions("$/teamproj/app1/app1/app1.csproj")
PS C:\> $defs | select TeamProject, Name, Uri
TeamProject Name Uri
----------- ---- ---
teamproj Continuous vstfs:///Build/Definition/2
teamproj Nightly vstfs:///Build/Definition/1
If you don't understand something let me know or look it up in the PowerShell docs. I am new to PowerShell myself, but I know some gurus.
I hope this simple example whets your appetite for PowerShell and the Team Build Object Model. More to come...