Team Building your windows 8 Metro style Applications.

Shady Youssef

Hi everyone, since this is my first blog post I’d like to introduce myself first. My name is “Shady Youssef Ibraheem” and I Joined Microsoft in June 2011 working as a software development engineer in test for Visual Studio Team Foundation Server, specifically for the Team Foundation build team. I hope that readers of this blog post find it helpful as I’m planning to publish a series of TFS Build specific posts very soon. If you have any suggestions about blog post topics regarding Team foundation Build please let me know, I’ll try to make it happen!

Today I’m going to walk you through building and testing your windows 8 “Metro Style” applications using team foundation build 2011 express. For the purpose of this walkthrough, I will be using the Consumer preview version of win8 , Microsoft Visual Studio 11 Express Beta for Windows 8 and Microsoft Visual Studio 11 Team Foundation Server Express Beta. Before we begin this walkthrough, it’s very important to understand 2 points.

  1. Windows 8 Metro Style applications will only build on a windows 8 machine. This means you can’t reuse your already existing build machines to build metro style applications.
  2. The newly released team foundation build hosted service provided to you on the team foundation service (TFS Preview) does not currently support building windows 8 metro style apps.

Step 1: Setup your development Environment:

Let’s start by Opening Visual studio for the first time on a win8 machine. You’ll notice that a window pops up prompting you to acquire a developer’s license. While a developer’s license is not required to create a metro style project or to build it, it’s required for deploying your built bits. And since any metro style app is pretty much useless unless deployed then you might want to install it. The process is pretty straight forward once you provide your live ID.

There’s also a handy command line tool which can be used to check/acquire and delete your developer license. It’s found under “C:Program Files (x86)Microsoft Visual Studio 11.0Common7IDETailoredDeploy.exe”. You can use this command line to install a developer license on your win8 build machine if you’re using separate development/build machines .If you need to deploy your builds for running tests during the build you might want to use this method or just open visual studio on the build machine to get the prompt above.

  • To Check if your machine already has a developer license:

TailoredDeploy.exe CheckDeveloperLicense

  • To Remove your current developer license:

TailoredDeploy.exe RemoveDeveloperLicense

  • To Acquire a developer license:

TailoredDeploy.exe AcquireDeveloperLicense

Step 2: Configuring your build machine:

Now we’re going to configure our on-premise team foundation build server on the win8 machine against our Team foundation Server instance.

  • Open your Team Foundation server management console and go to “Configure Team Foundation Build Service”.
  • Start the wizard.
  • In the “Project Collection” tab, browse for your team project collection on the team foundation server your wish to configure TFS Build against.
  • Select how many agents to create against your controller.
  • Since we’re going to be running tests during our build, and since Metro style tests need to be deployed and run inside the deployment sandbox, we need to run our build service interactively or else we will get a build error (feel free to skip this part if you’re not planning to run tests during your build).

( Could not start tailored test run because Unit tests for Windows Metro style app cannot be run from a service or non interactive process. Please run unit tests from an interactive process.)

  • Continue with the wizard (more information here).

Step 3: Creating and checking in your Metro style project:

Now you’re ready to create your win8 metro style project and add it to source control. Notice that Team Explorer is not shown by default in the express SKU so you’ll need to connect to your server via TeamConnect to Team Foundation Server…  You’ll then connect normally to your TFS server. You then create and edit your metro style project and check it into your Team Foundation Server’s version control repository. I’m using a solution that contains a c# Windows Metro Style Split Application project and a Metro Style Unit test project but feel free to experiment with other types of projects, who knows maybe your little test project there ends up being the newest hit app 😉

Notice that, by default newly created projects will have an exportable .pfx file (highlighted in red below). Those pfx files have an empty password by default but you can go on and change them. For this walkthrough we’re just going to leave them as is. Those pfx files are required for deploying your metro style projects and must be installed on the machine where your project will be deployed. Since we are planning to run tests during our build (which requires deployment as I mentioned earlier), we’ll need to manually install the certificates on the build machines running our build. If you’re only interested in building the app, then you can safely skip installing the certificates.

  • Installing the certificates on the build machine:
    • Copy the 2 certificates on the machines that have the agents building your app.
      •  Use the following command for every certificate you’re going to install where {***.pfx} is the path to that specific pfx file.

                                                                                                            Certutil –importpfx {***.pfx}

Now go ahead, do the changes you want to your app and check your code in (make sure you add at least a test case to the test solution).

Step 3: Create your build definition:

  • Open your team explorer and then go to the Builds hub

  • Create a new build definition
  • Fill in all the tabs as normal then open the process tab
  • We’re going to be using the default build template which should be selected by default.
  • In the items to build process parameter field, browse your version control repository for the .sln file you want to build. (If you have the solution open in solution explorer it will be selected by default J .
  • Now for the tricky part, to run tests using the default template, we’re used to specifying a wild card that will run all tests in sources matching the pattern “***test*.dll”. For Metro style tests this will not work. This is because like all metro style apps, test apps are packaged in the win8 package format that ends with *.appx. This means that we should either not use wildcards (IE: use the full names of expected test packages generated) or change the wildcard to “***test*.appx”.
    •  In the process tab, under basic. Select the Ellipsis to open the settings for “Automated Tests”.

  • Edit …
  • Make sure you’re using Visual Studio Test Runner.
  • Make sure you change the Test assembly file specification to “***test*.appx”.

  • Save your build definition.


We walked through the process of automating your builds of windows 8 Metro Style apps using Team Foundation Server 2011 Build. We saw how to create build definitions and we reviewed the required steps for running Metro Style Unit tests on our apps as a part of the build.  If you have any questions/feedback please don’t hesitate to ask.



Discussion is closed.

Feedback usabilla icon