Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

adamralph/simple-targets-csx

Repository files navigation

This project has been replaced by Bullseye. It is recommended to migrate your targets from simple-targets-csx to Bullseye.

Icon

simple-targets-csx

NuGet version Build status

A minimalist C# script library for writing targets for building, analysing, testing, packaging, deploying, etc. and running them using any runner which supports the "standard" C# script dialect (as defined by csi.exe).

In no way restricted to writing targets related to .NET projects.

Quickstart

  • Install (or download and unzip) the NuGet package.
  • Create a C# script named build.csx and add the following code:
#load "packages/simple-targets-csx.6.0.0/contentFiles/csx/any/simple-targets.csx" // change the path as required

using static SimpleTargets;

var targets = new TargetDictionary();

targets.Add("default", () => Console.WriteLine("Hello, world!"));

Run(Args, targets);

Usage

Action Command
Run a specific target {runner} .\build.csx targetname
Run multiple targets {runner} .\build.csx target1name target2name
List targets {runner} .\build.csx -T
List targets and dependencies {runner} .\build.csx -D
Dry run Append -n, e.g. {runner} .\build.csx -n or {runner} .\build.csx targetname -n
Skip running dependencies Append -s, e.g. {runner} .\build.csx -s or {runner} .\build.csx targetname -s
Show full usage details {runner} .\build.csx -?

Runners

  • csi.exe - Microsoft's "C# REPL Command-Line Interface". This is bundled with MSBuild 14 (and Visual Studio 2015) onwards so it's a good choice if you are using simple-targets-csx to write a build script for a .NET project, since the project will already likely have a dependency on MSBuild.
  • Dude - the portable C# script runner (csi.exe conveniently repackaged as a single self-contained exe). This is a good choice if you don't want or need to have a dependency on MSBuild. dude.exe can easily be downloaded and cached by a bootstrap command (similar to NuGet.exe in the example below).

Other C# script runners such as dotnet-script should also work.

Examples

xBehave.net uses a bootstrap command to

  • Download and cache NuGet.exe
  • Restore NuGet packages (including simple-targets-csx)
  • Execute its build script using csi.exe

Target by Franck Juncker from the Noun Project.