CS-Script moved to GitHub

CS-Script Source

This is the source code repository of the original CS-Script.

Currently it is used world wide for extending the applications functionality with scripting and as a general purpose scripting environment. It is used by both enthusiasts and by professional programmers. It found its way to non-profit organizations (e.g. educational institutes) as well as to commercial organizations. These are just a few examples: MediaPortal, FlashDevelop, K2 API, SF.net ("WinTin"), BonSAI, AyaNova (service management software)...
In 15 April 2014 (10 years after the first public release) CS-Script has been re-released under MIT license and since then its source code is hosted by this site (CodePlex Git). At the time of creating this repository CS-Script has been downloaded 239,477 times world wide.

At this site you will find:
For the in-depth online documentation please visit CS-Script Home Page.

The documentation will provide a complete overview of CS-Script functionality but few code snippets below can give you a quicke idea what CS-Script is about:

dynamic script = CSScript.Evaluator
                         .LoadCode(@"using System.Windows.Forms;
                                     public class Script
                                         public void SayHello(string greeting)
                                             MessageBox.Show(""Greeting: ""+ greeting);
script.SayHello("Hello World!");
var sqr = await CSScript.Evaluator
                        .CreateDelegateAsync(@"int Sqr(int a)
                                                   return a * a;
var sum = CSScript.Evaluator
                  .CreateDelegateRemotely<int>(@"int Sum(int a, int b)
                                                     return a+b;

int result = sum(15, 3);

var SayHello = CSScript.LoadMethod(
                        @"using System.Windows.Forms;
                          public static void SayHello(string greeting)
                          static void MessageBoxSayHello(string greeting)
                          static void ConsoleSayHello(string greeting)
                         .GetStaticMethod("SayHello" , typeof(string)); 
SayHello("Hello again!");

CS-Script can execute script files without an additional hosting solution. Just from the command prompt:
C:\> cscs ss_host.cs

Where ss_host.cs is a script for hosting ServiceStack REST server:
//css_npp asadmin;
//css_inc ServiceStack.cs;
using System;
using ServiceStack;

public class Host : ConsoleHost
    static void Main()
        new Host().Init()

        Console.WriteLine(@"AppHost listening on http://localhost:8080/
                            sample: http://localhost:8080/hello/John");

public class Hello
    public string Name { get; set; }

public class StatusService : Service
    public object Get(Hello request)
        return new
            Message = $"Hello {request.Name}!",
            Timestamp = DateTime.Now.ToString()
You can also use take an advantage of CS-Script dedicated fully featured IDE (Intellisense, execution, debugging, packaging) built on top of Notepad++.

How to build binaries
Source code includes <root>\Build\build.cmd, which builds all CS-Script binaries.

It also includes VS2015 solution for building script engine executable and the class library assemblies to allow more convenient debugging, troubleshooting.

How to install CS-Script on Windows
You can download the package from the Downloads page and deploy the package content manually (the procedure is described at the end of this section). Alternatively you can use Chocolatey, which is a preferred way of installing.

Chocolatey is the repository for the Windows software packages. Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind.
It is also the source repository of the OneGet package manager of Windows 10.

CS-Script can be installed with the following command:

C:\> choco install cs-script

Read more on Chocolatey and how to enable it on your version of windows here: https://chocolatey.org/

Note, by default support for C# 6.0 is disabled. Instructions on how to enable it can be found here: http://csscriptsource.codeplex.com/releases/view/616791

How to host script engine in the application

You can use Visual Studio console application project and NuGet package as the starting point.

PM> Install-Package CS-Script

After installing the package the VS project will include the scripting.cs file containing the samples for all supported hosting scenarios.

Manual installation

Using Chocolatey is a preferred delivery machanizm for CS-Script. The reason is simple. It allows avoiding manual downloading which can lead to silent sneaky disabling of the downloaded content by latest Windows security features. Though you may still have your reasons for the manual installation.

The first step is to download the package and extract the binaries. Be careful there is a huge chance that Windows will silently lock your package and its extracted content preventing it from running. The simplest way to avoid it is to use 7Zip client.

After that you can continue by executing css_config.exe, which does the install.

Well it's is not truly an "install". CS-Script only needs a few environment variables to be set and a config file created. Even if this is not done it will not prevent you from using CS-Script. The absence of the config file will trigger the use of the defaults and not having envars may not necessarily affect your experience. Thus if for whatever reason you cannot/don't want to execute css_config you can do the rest of install manually as well:

1. Add <cs-script> directory (folder with cscs.exe) into your system PATH
2. Add CSSCRIPT_DIR envvar with value "<cs-script>"

That is it.

If you still want to use config file then you can create it (<cs-script>\cssconfig..xml) and use the default content from here: https://github.com/oleg-shilo/cs-script/blob/master/Source/cssconfig.default.xml

Last edited Mar 21 at 1:12 AM by oleg_s, version 33