Skip to content

Latest commit

 

History

History
115 lines (77 loc) · 6.72 KB

README_BODY.md

File metadata and controls

115 lines (77 loc) · 6.72 KB

C# script tool for

NuGet TeamCity.csi GitHub

This is a repository of TeamCity.csi which is an interactive tool for running C# scripts. It can be used as a TeamCity build runner or installed as a command-line tool on Windows, Linux, or macOS.

Prerequisites

The tool requires .NET 6+ runtime.

Use Inside TeamCity

Currently, the tool can be used as a TeamCity build runner provided in terms of TeamCity 2021.2 Early Access Program. Read the runner's documentation for more details.

Use Outside TeamCity

After installing tool you can use this tool independently of TeamCity, to run C# scripts from the command line. TeamCity.csi is available as a NuGet package.

Before installing TeamCity.csi as a local tool dot not forget to create .NET local tool manifest file if it is not exist:

dotnet new tool-manifest

Install the tool and add to the local tool manifest:

dotnet tool install TeamCity.csi

Or install the tool for the current user:

dotnet tool install TeamCity.csi -g

Launch the tool in the interactive mode:

dotnet csi

Run a specified script with a given argument:

dotnet csi Samples/Scripts/hello.csx World 

Run a single script located in the MyDirectory directory:

dotnet csi Samples/Build

Usage:

dotnet csi [options] [--] [script] [script arguments]

Executes a script if specified, otherwise launches an interactive REPL (Read Eval Print Loop).

Supported arguments:

Option Description Alternative form
script The path to the script file to run. If no such file is found, the command will treat it as a directory and look for a single script file inside that directory.
script arguments Script arguments are accessible in a script via the global list Args[index] by an argument index.
-- Indicates that the remaining arguments should not be treated as options.
--help Show how to use the command. /?, -h, /h, /help
--version Display the tool version. /version
--source Specify the NuGet package source to use. Supported formats: URL, or a UNC directory path. -s, /s, /source
--property <key=value> Define a key-value pair(s) for the script properties called Props, which is accessible in scripts. -p, /property, /p
--property:<key=value> Define a key-value pair(s) in MSBuild style for the script properties called Props, which is accessible in scripts. -p:<key=value>, /property:<key=value>, /p:<key=value>, --property:key1=val1;key2=val2
@file Read the response file for more options.

using HostApi; directive in a script allows you to use host API types without specifying the fully qualified namespace of these types.

Debug scripts easy!

Install the C# script template TeamCity.CSharpInteractive.Templates

dotnet new -i TeamCity.CSharpInteractive.Templates

Create a console project "Build" containing a script from the template build

dotnet new build -o ./Build

This projects contains the script ./Build/Program.csx. To run this script from the command line from the directory Build:

dotnet csi Build

To run this script as a console application:

dotnet run --project Build

Open the ./Build/Build.csproj in IDE and debug the script.

Report and Track Issues

Please use our YouTrack to report related issues.