The C# Script runner allows executing a C# script on Windows, Linux, or macOS. It uses a custom TeamCity tool for running a C# Interactive shell across platforms.
With this runner, you can perform various service tasks, such as preparing a build environment, creating an OS user, or reporting to different messengers.
The runner's requirements:
C# Script Settings
TeamCity C# script tool
Select a version of the TeamCity C# Script tool from those installed via Administration | Tools, or enter a custom path to this tool, relative to the build checkout directory.
Choose one of the two options: enter a custom script body right inside the runner or specify a path to a C# script file (
Available for the Custom Script type.
Enter a code of a C# script.
C# script file
Available for the Script File type.
Enter a path to the script file, relative to the build checkout directory.
Enter parameters of the script. Parameters are passed as the
Parameter references are supported.
NuGet package sources
If you refer to a package from a script, TeamCity will automatically download it from the feed specified in this field. The runner can automatically parse commands like
By default, TeamCity restores NuGet packages from their sources published on NuGet.org. In this field, you can specify paths to other NuGet repositories, and TeamCity will search for packages there, by the order of declaration. If a package source cannot be found in any of the specified repositories, TeamCity will search for it on NuGet.org.
To be able to access private repositories, configure NuGet feed credentials.
You can also refer a TeamCity internal feed.
Commands and Arguments Supported in Scripts
Add a reference to a NuGet package or an assembly and its dependencies.
Load the specified script file and execute it.
Display Help on available commands and key bindings.
Set a verbosity level to
arguments provided in the Script parameters field and stored in the
Argsarray (for example,
WriteLine(Args)to write the value of the first script parameter);
system parameters specified in Build Configuration Settings | Parameters and stored in the
Propsdictionary (for example,
WriteLine(Props["version"])to write the value of the