CS-Script 3.20.0

Compile to assembly (use pre-compiled) 

/c - use compiled (pre-compiled)

In this mode the script engine stores a compiled script file (assembly) in the same location as the script file and executes it next time instead of compiling the script again if the script has not changed since last execution. This mode is used to improve runtime performance.

The script caching mechanism is based on sophisticated algorithm for analysing if the script is changed. It includes analyse  of the timestamps of the script file and all it's dependencies (imported scripts and referenced assemblies)

The compiled script file is an assembly file with the same name as the script file and extension .compiled

The script engine searches the script file directory for corresponding .csc file at start up. If file found and it has the same timestamp as the corresponding .cs file the engine loads it and executes without any compiling. Otherwise script engine compiles .cs file into .csc first and only after that loads and executes it.

The compiled script file stays along with the script file after script execution.
cscs /c test

The command above executes the test.cs script in a "use compiled" mode. 

The performance improvement in this mode can be quite significant. In general, the overall performance is influenced by two components: startup delay and runtime performance. The runtime performance of the script is absolutely the same as the equivalent executable.  However startup delay has to be longer for a script as it involves script engine initialization, script analysis and compilation... Running scripts with /c switch is like running Web browser in cached mode. The measurements of startup delay for a script on the average PC (P4 2.8GHz 1G of RAM) shows about 45-60 ms overhead comparing to a standalone executable.  Thus measured execution time for the  standard hello.cs script was consistently around 110 ms.
Note: performance figures may vary from version to version.

Note: Because .csc file is just an assembly it is guaranteed to be valid only within the environment it is compiled on. It means that if you copy the script and it's .csc file on another PC with different .csc may not be valid there. Proper .config files will solve the problem in most of the cases (CS-Script is deployed with .config files for all script engine executables). If problem cannot be solved for what ever reason just delete .csc file and it will be generated correctly with the next script execution. 

/ca - compiles the script file into assembly (.csc) 

cscs /ca test
The command above compiles the test.cs script into compiled assembly test.csc without actual execution.  

/cd - compiles the script file into assembly (.dll) 

cscs /cd test

The command above compiles the test.cs script into compiled assembly test.dll without actual execution. This mode is logically identical to /ca . It differs only in the file extension. This mode is useful for converting a script to the assembly form for use in other applications (as any other class library assembly).  

See Also

Command-line interface