mars 10

Few days ago, I was needing to be able to retrieve some informations about the builds we had launched. I was so needing to work with the TFS API.

To do this, you must have Visual Studio and a Team Explorer installed.

  1. Create a new application (a console application for example)
  2. Add a reference to the DLLs
    1. Microsoft.TeamFoundation.Build.Client
    2. Microsoft.TeamFoundation.Build.Common
    3. Microsoft.TeamFoundation.Client
    4. Microsoft.TeamFoundation.Common
You can find these DLLs in the folder "Program Files\Microsoft Visual Studio X.X\Common7\IDE\Private Assemblies
And after you can very simply interrogate the TFS API as for example :

string tfsUrl = "http://YourTFS:8080";

string teamProject = "Your Team Project Name";

string teamBuildType = "The name of your team build";

 

//Connect to the Team Foundation Server using the credentials

//of the currently logged person

TeamFoundationServer server = TeamFoundationServerFactory.GetServer(tfsUrl);

//Access the build service

BuildStore buildStore = server.GetService(typeof(BuildStore)) as BuildStore;

//and get the list of builds

BuildData[] buildDatas = buildStore.GetListOfBuilds(teamProject, teamBuildType);

 

//Iterate on all your builds

foreach ( BuildData buildData in buildDatas )

{

   PlatformFlavorData[] platforms = buildStore.GetPlatformFlavorsForBuild(buildData.BuildUri);

 

   // Iterate, for a specific build,

   // on all the build platform and flavor you have defined

   foreach ( var platformFlavor in platforms )

   {

      TestResultData[] testResults = buildStore.GetTestResultsForBuild(buildData.BuildUri, platformFlavor.PlatformName, platformFlavor.FlavorName);

 

      foreach ( TestResultData testResultData in testResults )

      {

         /* Here for each build platform and flavor

         * you are iterating on the test results

         */

      }

   }

}

Quite easy no ?

Juste one things to know : this code will work, whatever the version of your Visual Studio and TFS. But all the class you use here are deprecated under TFS 2008 (but will still work).

So how to do the same thing using the new TFS 2008's classes ? To be seen in a future post ! ;-)

mars 06

Today, I wanted to create a new Performance Session in Visual Studio to trace an detect some slowly parts in my web application application.

So it easy, I use the wizard to select my website and the different DLLs I want to instrument, I launch everything and what do I get ?

Launch Error: The web site could not be configured correctly; getting ASP.NET process information failed. Requesting 'http://localhost:48185/MyAspApp/VSEnterpriseHelper.axd' returned an error: The information returned is invalid.
PRF0017: Can't launch server for 'C:\.....\Project'.

What's happen ? I have found some information on Microsoft's website and on some blogs.

Here are two things you can check to correct the error

  • Be sure your website / web app uses dynamic port
  • Be sure you website / web app do not use forms authentication
    • If it's the case, correct it to add a tag allow users="?" and allow users="*" 

In my cases, it has resolved my problem.