An open API service indexing awesome lists of open source software.

https://github.com/adamralph/simple-targets-csx

⊙ A minimalist target runner for C# scripts.
https://github.com/adamralph/simple-targets-csx

build csharp csi csx csx-script dotnet task-runner

Last synced: 5 months ago
JSON representation

⊙ A minimalist target runner for C# scripts.

Awesome Lists containing this project

README

          

**This project has been replaced by [Bullseye](https://github.com/adamralph/bullseye). It is recommended to migrate your targets from simple-targets-csx to Bullseye.**

![Icon](/assets/simple-targets-csx.png)

# simple-targets-csx

[![NuGet version](https://img.shields.io/nuget/v/simple-targets-csx.svg?style=flat)](https://www.nuget.org/packages/simple-targets-csx) [![Build status](https://ci.appveyor.com/api/projects/status/cmkx89k0sj0h3ebw/branch/master?svg=true)](https://ci.appveyor.com/project/adamralph/simple-targets-csharp/branch/master)

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](https://msdn.microsoft.com/en-us/magazine/mt614271.aspx)).

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

### Quickstart

* Install (or download and unzip) the [NuGet package](https://www.nuget.org/packages/simple-targets-csx).
* Create a C# script named `build.csx` and add the following code:
```C#
#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);
```
* Run `csi.exe .\build.csx` (see ["Runners"](#runners)).

### 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](https://msdn.microsoft.com/en-us/magazine/mt614271.aspx) - 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](https://github.com/adamralph/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](https://github.com/filipw/dotnet-script) should also work.

### Examples

xBehave.net uses a [bootstrap command](https://github.com/xbehave/xbehave.net/blob/dev/build.cmd) to

* Download and cache `NuGet.exe`
* Restore NuGet packages (including simple-targets-csx)
* Execute its [build script](https://github.com/xbehave/xbehave.net/blob/dev/build.csx) using csi.exe

---

[Target](https://thenounproject.com/term/target/345443) by [Franck Juncker](https://thenounproject.com/franckjuncker/) from [the Noun Project](https://thenounproject.com/).