Skip to content
oleg.shilo edited this page Mar 14, 2021 · 39 revisions
Since porting CS-Script on .NET 5 the documentation is still in the process of being refined and cleared from the legacy content.
Thus it may contain some minor inaccuracies until both statuses below are set to full and complete or this disclaimer is removed.
.NET 5 accuracy status: full
Review/update status: completed

CS-Script


CS-Script platform is used worldwide 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 nonprofit 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 on GitHub. At the time of creating this repository CS-Script has been downloaded ~270,000 times world wide. And more than 1,000,000 (at Jul 2017) via Notepad++ plugin manager.

At this site you will find:

How to use CS-Script resources

  • This very website (GitHub Wiki) is the best place to search for the latest documentation. Particularly regarding the hosted script execution as it is the most dynamic and actively changing part of the CS-Script interface/functionality. This is where you can find the most concise information about the mainstream features of CS-Script. It is also the place where you can ask the questions, make feature requests and report defects.

  • The all released packages (including NuGet) contain CSScriptLib.chm file, which is an offline documentation for the CSScriptLib.dll assembly. This is the assembly that you need to uses if you need to host CS-Script engine in your application. While it is a true API (not user manual) documentation it is full of code samples that can be extremely useful during the development. This documentation is a SandCastle compiled version of the API XML documentation (CSCSriptLib.xml). Thus it is also immediately and fully available via your IDE like VSCode or Visual Studio.

  • The easiest way to access the most versatile form of documentation for CS-Script CLI is the help output of the script engine itself (cscs.exe or css.exe). Just execute it with the -? or -help argument and it will print the whole help document.

  • It is recommended (but not required) that you use an IDE when working with CS-Script.

    • Windows Just run the script with -vs argument and it will open Visual Studio and load the complete script project created on-fly: css -vs script.cs

    • Linux/Windows You can either load the existing script into it with css -vscode .\script.cs or create a new script within the IDE if you install the CS-Script extension. Alternatively you can open the file in VSCode with its own CLI command: code .\script.cs.

Overview

The documentation is an excellent starting point for exploring CS-Script features. But if you want just to dive in then jump to the How-to guide.

CS-Script comes in two forms: CLI for stand alone execution and a class library for hosting script engine in applications. CLI can be installed from Choco (or Releases). And Nuget package (class library) from https://www.nuget.org/packages/CS-Script.

Hosting samples can be found here.

How to build binaries Source code includes src\1.build-binaries.cmd, which builds all CS-Script binaries.

It also includes VS2019 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: C#6.0 support

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 (\css_config..xml) and use the default content from here: https://github.com/oleg-shilo/cs-script/blob/master/Source/css_config.default.xml