How to run White + SL4 UATs through TeamCity?

Hi All,

After experiencing a series of unpleasant issues with TFS, including source code corruption and project management inflexibility, we (meaning the project team of which I'm a part) have decided to move from TFS 2010 to TeamCity + SVN + V1.

I've managed to get our MSTest component and unit tests running as part of every build.  However, our UATs are failing, and I was hoping for some advice from the TeamCity community as to best practices w.r.t. running web servers and interacting with the desktop.

Each of our UAT fixtures starts a web server to host the site, like this:

public static void StartWebServer()
     var pathToSite = @"C:\projects\myproject\FrontEnd\MyProject.FrontEnd.Web";
     var webServer = new Process
          StartInfo = new ProcessStartInfo
               Arguments = string.Format("/port:9150 /path:\"{0}\"", pathToSite),
               FileName = @"C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE"

Needless to say, this doesn't work when running through TeamCity, as the

value is different each time. I'm hoping there is a way of determining the path into which the the code is checked out prior to building?  That would allow me to point the web server at the right place.

The other issue is that our UATs use White to drive the Silverlight UI through an instance of Internet Explorer:
_browserWindow = InternetExplorer.Launch("http://localhost:9150/index.html#/Home", "Home - Windows Internet Explorer");
_document = _browserWindow.SilverlightDocument;

I've ensured that the TeamCity service is granted the ability to interact with the desktop, and I've set the build agent machine up to log in automatically (an open session is a pre-requisite for White to work properly).  Is that all I need to do or are there additional steps required?

TIA for any advice ...

Duncan Bayne


TeamCity exports checkout directory as system property called ''. This property will be available for MSBuild script as $(system_build_chekoutDir). You may create new environment varialbe in build configuration settings (5. Properties and Environment variables) with value

In .NET you may access environment variables by Environment class.

Another way to find a path is connected with .NET assebmlies. To get the location of current assembly use the following code:
new Uri (this.getType().Assembly.CodeBase).LocalPath
Knowning where test assebmly is located should be enough to compute path of the web site location.

Do you run build agent from LOCAL_SYSTEM account? Please try changing it to the same account as set to autologin.
Another way to run build agent from user session is to disable build agent service and start using <agent home>/bin/agent.bat
This script will start build agent in console mode. You may try this to check weather service security breaks White tests.

Please have a look to related documentation pages:


Thanks - that's the answer.  Although, with the current version of TeamCity (5.1.2), Properties and Environment Variables is now Section 6.  Also, the variable name has changed to


Please sign in to leave a comment.