It is possible to pass come compiler options directly to the code compiler (e.g. Microsoft C# compiler csc.exe) directly from the script code:
options - compiler options as per csc.exe compiler command line interface.
static string code = @"using System; public class Script { public static void Print(string greeting) { #if USE_TIMESTAMP Console.Write(DateTime.Now.ToString() + "":""); #endif Console.WriteLine(greeting); } }" ... //executing code with USE_TIMESTAMP defined Print = CSScript.LoadCode("//css_co /define:USE_TIMESTAMP;\n" + code) .GetStaticMethod(); |