Setup TeamCity on an Azure Virtual Machine for Windows 8 Metro Style Apps

I’ve been using TeamCity for a couple years now. Previously I installed Cruise Control (the mother of all CI servers or PSake a script-based solution). This post gives you some advice on how to setup a continuous build for your project. It’s mainly configured like a classic .NET project, the only difficulty lies in the tests configuration since it’s a new kind of runner.

  1. Create a new virtual machine with Windows Server 2012

1CreateVM

  1. Create a new endpoint for the port 80 on TCP (or the port on which Team City will listen)

2EndPoints

  1. Attach a new data disk to be able to migrate more easily the TeamCity server to another machine

3AttachDisk

  1. Connect trough the toolbar and format the new data disk: tap Windows key >; tap “Computer” and choose “Computer Management”. You should see the following popup. After initializing it, right click on it and choose “New Simple Volume” to format it and assign a letter (here F:).

4FormatDisk

5Disks

  1. Install Visual Studio Express 2012 and activate NuGet restore (the packages are not in my source control repository since NuGet has a feature to restore the packages at build-time). Click on Acquire a developer license in the STORE menu.

7nugget

You can disable the infamous IE Security here:

6IESecurity

  1. Install Team City on the new Data Disk. Uncheck the Service option for the build agent since we are going to use the command line start option. And change the location of the data directory (by default it’s on the OS disk under the ProgramData directory) by changing the environment variable (http://confluence.jetbrains.net/display/TCD7/TeamCity+Data+Directory)

8TeamCity_NoService

  1. Add a Firewall rule to enable the port 80

9Windows_Firewall

7a) Create a user with all access to the TeamCity agent folder, give it the remote access control of the server

  1. Install Git http://code.google.com/p/msysgit/

  2. Add a new build configuration with Git as the VCS :

add a ssh key to your account by following those instructions: https://help.github.com/articles/generating-ssh-keys

And now you can use this key to checkout the code with TeamCity:

13Git_1

13Git_2

  1. Add a build step and choose Visual Studio with the path to the sln file. Choose Publish as the target.

11Step_Build

  1. Start the agent manually in (F:\TeamCity\buildAgent\bin) : agent.bat start and run your build configuration to check that the solution can be build.

  2. In Visual Studio 2012 you have the new Test Explorer Window to see and execute your tests. You also have a command line version of this runner. I was not able to run the agent as a service because the test runner needs an interactive process.

On the server, run this command from the Unit Tests project directory:

[sourcecode language=“text”] Certutil –importpfx thenameofthecertificate.pfx [/sourcecode]

with the actual filename found in the directory of the test project (by default the password is blank). You should see the following lines:

[sourcecode language=“text”] Certificate “CN=XXX” added to store. CertUtil: -importPFX command completed successfully. [/sourcecode]

  1. Add a Command line step for each project with this script:

[sourcecode language=“text”] “C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\ IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe” F:\TeamCity\buildAgent\work\(…)\AppPackages\(..)\filename.appx /InIsolation [/sourcecode]

The argument is the appx file created under the AppPackages directory.

12Step_Tests

  1. Run your build configuration

10Success

Green is good :)

billet publié dans les rubriques coding le