Out of the box support

The TeamCity alias, which returns an ITeamCityProvider instance can be used to interact with the TeamCity environment.

The following example writes an error message if running on TeamCity:

if (BuildSystem.TeamCity.IsRunningOnTeamCity)
            "This is a error message.",
            "Error details."
    Information("Not running on TeamCity");

See ITeamCityProvider for details and available methods to interact with TeamCity.

Available 3rd party extensions

Cake.TeamCityCoverageReporter by wozzo17, thnk2wn
Addin to enable code coverage reporting from an OpenCover result XML file to TeamCity