When using TeamCity as my CI server, my personal preference is to use the Command Line runner. I feel that this gives me the ultimate flexibility, as it is easy to pass parameters to a batch file, and the batch file can in turn be invoked to run a Nant script. It also ensures that my local build experience is as close as possible to what is happening on the build server.
What can I say? I am a control freak when it comes to this stuff.
Recently I was setting up a new build configuration and was having trouble passing in TeamCity environment variables. I tries a stack of variations on the theme but couldn’t seem to crack the right syntax. So here preserved in all its glory is the correct way to pass the environment variables to the command line.
1. Select ‘Add New Variable’ under Environment Variables in your build configuration
2. Define your variable name and value

When saved the variable will be renamed slightly and will appear like…

3. Add the syntactically correct reference to your command line parameters

The trick is to include the '%' symbol markers and also the 'env.' prefix on the name that you defined.
Enjoy!