Developing Windows Phone applications for Team Foundation Server
Finally Microsoft has released something that should make all TFS and WP7 aficionados very happy. Microsoft (MS) has made access to the TFS Object Model via the Open Source OData protocol, and to boot MS has also provided a sampler to start playing with via hosting the OData Service on Windows Azure (WAZ) for the Codeplex TFS projects. This WAZ OData Service endpoint acts as an intermediary for your clients such as a browser or a Windows Phone Device (WP7) or a Web Matrix Client, talking to the Codeplex TFS Collections. These various Clients can talk to TFS using OData protocol without having to worry about either the TFS Web Services OR the TFS Object Model.
You can read all about what OData is and how to use it etc.,. from our Tech Evangelist Brian Keller’s blog post. For all golden references you should always refer to Brian’s post. The objective of my post is to cover the end user actually using the documentation and playing around with it. Now let’s get started.
While working through the document and sample I came across a few hitches, which I thought others might also hit and scratch their head. If you did and hit this post, then you saved some worry in the process.
Once you download the kit referenced in Brian’s post above, you will have to run the setup.cmd in the folder C:\ OdataforTfsSample (C:\ may vary depending on where you extracted the download) . When you run it , it goes through a series of checks to make sure all PRE-REQs are there and if not, point you to a download location to download and install and then re-run the PRE-REQ check. For the most part the setup.cmd script works and does its intended job well. However I noticed one snafu where it does not detect the installed Windows Azure Tools.
At the below point in this check, you will hit a setup issue, where even if you had the required bits, it will not go past this check and make you wonder whether you hit some weird packaging issue in your system.
So when it reaches the point where it checks for the Windows Azure Tools (WAZ) , you might or might not have the latest download of WAZ on your machine. As you can see it references the November 2010 version, whereas the download link will take you to the March 2011 link. And even after you installed wherever the download link took you to, and then re-run the scan to continue it will fail at this step. This is because there is a bug in the Setup and it checks for specific strings which it is not going to find and so it fails. In case you hit this, you can still continue to proceed after making sure the WAZ March 2011 was downloaded and installed and then going on to install the succeeding 2 (See below) components in the scan check namely Windows Phone Tools and Microsoft Web Matrix Beta 3 (the latter is not required if you are not targeting Web Matrix as a client).
So once you are past this, you should be able to load up the solution file in Visual Studio and then make the necessary changes in your web.config and .CSCFG file as mentioned in the Readme.html links ( from doc folder of your OdataforTfsSample ) and then build and deploy the solution.
The Browser Experience
This one is for deploying your own OdataService to the Cloud and if you wanted to browse to the data from there. You can browse to the data from the browser and as well as from the Windows Phone. I show browsing from both the experiences as a point of demonstrating how the OData protocol makes it easy to expose your TFS Services, instead of having to expose it directly for these kinds of access. So we will see how to view it from a standard browser such as IE9 and as well as from a WP7 device. But before that we have to take care of some business such as having a certificate to trust the Client to the server.
The below steps are for deploying the certificate for accessing the OData Service on your WP7 device. Once you have deployed the certificate then you can browse to the OData End Point. Let’s first do that and get it out of the way, so that then we can see the various browser experience subsequently.
Deploying the certificate onto the WP7 device.
Open the ODataTFS.sln file in Visual Studio, from the folder where you downloaded the bits.
Copy the 127.0.0.1.cer file from the setup\assets folder and bring it into the solution. If the certificate does not exist you will have to create it and manually copy it. The end result of the cert creation and copying is it should be part of your solution.
Once you are done with that, press F5 to compile the solution. Now go to your WP7 Phone emulator and do the following to deploy the certificate. This is an independent step and has got nothing to do with viewing the data on a browser such as Internet Explorer.
Enter the URL https://127.0.0.1/127.0.0.1.cer into the Phone browser. Then you should see the below. Press the armor plate icon to deploy the Certificate to your phone and then click on Install and then on OK as below. I showed all three screens in succession as below.
From then on, you should be able to browse to the TFS OData Service URLs from your Windows Phone. I provide just one example, where if you had the OData provider end point on http://127.0.0.1/tfs09 you would have the following output.
This shows that how you can take the OData Service Provider bundle and create your own end points. And that can be the topic of another post by itself. At this point you might be wondering what’s the big deal – I got a bunch of Text Goo OR XML data. Yeah the output looks raw XML. But this is where you could use all of the Phone UI stuff and do some cool data presentation and interaction.
Now for viewing the OData Service Endpoint provided data on the Browser.
Point your browser to the appropriate URL for the OData end point and enter credentials if prompted.
Of course you can browse the data only if you have a user id on one of the Codeplex projects.You will need to know the following to authenticate via the provider to your CodePlex project.
In my case when I browse to the following URL (in your case it could be entirely different) I get the following.
After entering the codeplex credentials, I get the following.
Now for the Windows Phone Client Experience.
Open the solution ODataTFS.Mobile.sln file which you downloaded. See C:\ODataForTfsSample folder or wherever you downloaded the bits.
Set your deployment target to the appropriate device. It could be either the WP7 emulator or the Windows Phone itself.
For the sake of putting pictures here, I am showing deploying to the emulator. You can either go to Build->Deploy from the menu or just hit “F5” and it will bring up the emulator.
Click on the “OData TFS Client” WP7 App and enter the login data with the appropriate end point and click on the “Login” button.
Once you are past the login you should see the OData Service provided data as follows:
Now you could click on any of the various TFS artifacts such as WorkItems or Changesets to browse through the data. I clicked on Changesets, and got the data below.
And once again, at this point you might be wondering what’s the big deal – I got a bunch of Text Goo OR XML data. Yeah the output looks raw XML. As I said before, this is where you could use all of the Phone UI stuff and do some cool data presentation and interaction and well, yeah that could be the topic of another blog post.
For now enjoy getting your TFS data on your WP7 device.
Additional information regarding OData API
For those who are interested in knowing more about the OData protocol itself and Microsoft’s Release of OData the following links will be useful.
Technorati Tags: TFS Windows Phone WP7