Compiling (and caching) to a .dll
Let's assume we have a file named server.csx. By default when you run scriptcs with no additional parameters scriptcs server.csx
, your .csx file is compiled and executed in memory.
If you are always running the same code, this takes more time than necessary since a new compilation always takes place.
We have introduced the -cache
flag, which allows you to compile to a .dll once and use it to avoid unnecessary builds when no changes have been performed. You can take advantage of this feature by invoking scriptcs server.csx -cache
.
The .dll files are written to a hidden .scriptcs_cache directory. At the time of writing (December 4th, 2013) when you provide the -cache
flag, a check is performed to see if a file named %scriptFileName%.dll exists inside a .scriptcs_cache folder located in the current working directory. In this case, the check would be for server.dll.
- If the assembly exists, it is automatically loaded and the script is executed.
- If the assembly does not exist:
- Compile the script into a .dll.
- Write the .dll to the .scriptcs_cache directory.
- Execute the script.
As you probably deduced after reading how the feature works, you will need to manually delete the .dll inside the .scriptcs_cache folder (or the .scriptcs_cache folder altogether) if you perform changes to your .csx files and want them compiled into a .dll.
There is still a long way to go, but we are working on this. The idea is to detect if any of the cached .dll dependencies (.dll or .csx files) have changed since it was created.
- Home
- Build scriptcs
- Building on Mac and Linux
- Using scriptcs
- The command line
- Package installation
- Writing a script
- Compiling (and caching) to a .dll
- Debugging a script
- REPL
- Running scripts in Atom
- REPL
- Script Packs
- Script Libraries
- Modules
- Hosting
- Community
- Known Issues