How To Provide Additional Data To MSBuild From TeamCity

Command Line

If you run MSBuild from the command line, you can use the “property” injector command line argument. This is basically a key value pair.

e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe <PathToMSBuildProjectFile> /t:Run /p:Configuration=Release /p:Property1=Value1



You can use the same construct also in TeamCity:



The problem arises if you have

  • more than one build step in a build configuration
  • more than one build configuration

which all use the same parameters.

Use Build Parameters

TeamCity provides the support of build parameters (

With this approach, the build parameters are automatically provided to the MSBuild command line. You have to use System Properties to achieve this goal:


Where to put Build Parameters

There are two possiblities where to put them:

  • build configuration
  • build project

Build Configuration

If you put the build parameters to Build Configuration, they are for this build configuration only.


Build Project

If you add the build parameters to the BuildProject, they are “inherited” by all build configurations of this project.



If one or more of the parameters are different for a build configuration, you can still overwrite it in the build configuration’s Build Parameters: