Skip to content

Latest commit

 

History

History
141 lines (98 loc) · 8.06 KB

README_BODY.md

File metadata and controls

141 lines (98 loc) · 8.06 KB

Build automation system for .NET

NuGet csi GitHub GitHub Build

C# interactive build automation system makes it easy to build .NET projects. It can be part of your solution as a regular .NET console project or run C# scripts without compiling them, or even run in REPL mode - allowing you to run C# interactively.

Key Features

✔️ Three Integrated Execution Modes

Flexible interoperability between modes for diverse workflow requirements.

✔️ Native Cross-Platform Support

Seamless operation across Windows, Linux, and macOS environments.

✔️ Debugging Support

Ability to debug in “.NET build project” mode, allowing developers to efficiently identify and fix problems during the compilation and build process.

✔️ Zero Abstraction Constraints

No restrictive abstractions (e.g., Tasks, Targets, DependsOn) to limit script design:

  • Pure .NET codebase – no proprietary syntax or hidden layers
  • Adheres to industry-standard coding practices for maintainability

✔️ Powerful API for building .NET projects

Granular control over builds, tests, and deployments with streamlined project configuration.

✔️ Summarised statistics

Consolidated build statistics.

Operating modes

Interactive

REPL (Read-Eval-Print-Loop) interface for interactive code evaluation. Please see this page for installation details.

Launch the tool in the interactive mode:

dotnet csi

Simply enter C# commands sequentially one line after another and get the result in console output.

Running C# script

Direct execution of C# scripts without prior compilation:

  • Zero-Compilation Workflow - execute .csx files directly using Roslyn scripting engines, bypassing traditional dotnet build steps for rapid iteration.
  • Cross-Platform Scripting
    • Windows - integrate with PowerShell/PowerShell Core automation pipelines
    • Linux/macOS - combine with bash/zsh scripts via shebang directives (#!/usr/bin/env dotnet-script)
    • Dependency Management - resolve NuGet packages in scripts via #r "nuget: PackageName/Version" syntax, with local cache optimization.

Run a specified script with a given argument:

dotnet csi ./MyDirectory/hello.csx World 

Run a single script located in the MyDirectory directory:

dotnet csi ./MyDirectory World
Usage details
dotnet csi [options] [--] [script] [script arguments]

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

-- - Indicates that the remaining arguments should not be treated as options.

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.

@file - Read the response file for more options.

Supported options:

Option Description Alternative form
--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
.NET build project

Seamless integration into existing solutions as a standard .NET console project. Please see this page for details on how to install the project template.

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

dotnet new build -o ./Build

The created project contains 2 entry points:

  • Program.csx to run as a script
    dotnet csi ./Build
  • Program.cs to run as .NET application
    dotnet run --project ./Build

NuGet packages

Package name Link Description Installation
dotnet-csi NuGet Interactive .NET tool for REPL and running scripts dotnet tool install --global dotnet-csi
CSharpInteractive.Templates NuGet .NET build project template dotnet new install CSharpInteractive.Templates
CSharpInteractive NuGet A library for use in .NET build projects dotnet add package CSharpInteractive

Usage examples