oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.61k stars 235 forks source link

Upgraded to CS-SCript 4 version and unable to find UseAlternativeCompiler setting. #330

Closed caesarm closed 1 year ago

caesarm commented 1 year ago

I was trying to migrate from CS-Script.bin 3.30 package to CS-Script 4.6.5 version and cannot find a way to use the CSSCodeProvider to specify VB for the script. The UseAlternativeCompiler settings seems to be removed from the GlobalSettings.

CSScript.EvaluatorConfig.DebugBuild = Application.IsDebugBuild;
CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
CSScript.EvaluatorConfig.Access = EvaluatorAccess.Singleton;
CSScript.GlobalSettings.UseAlternativeCompiler = Assembly.GetExecutingAssembly().Location;

Is this still supported?

oleg-shilo commented 1 year ago

In CLI interface the alternative compiler is still supported but for the hosted execution (your case) only CodeDom and Roslyn engines are supported currently.

Saying that you can specify your custom compiler but I do not know if it will work straight away:

CodeDomEvaluator.CompileOnServer = false;
Globals.csc = @"your vbc.exe file";
caesarm commented 1 year ago

I did find one issue. A small change is needed in the CodeDomeEvaluator class. The -define argument for vbc.exe takes a comma delimited list of constants and errors with a semicolon as the delimiter. I downloaded the source for 4.7.1.0 and tested the changes below.

Changed line 226 to this common_args.Add("-define:TRACE,NETCORE,CS_SCRIPT");

Maybe an easier fix for both cases is to add a define argument for each constant.

common_args.Add("-define:TRACE");
common_args.Add("-define:NETCORE");
common_args.Add("-define:CS_SCRIPT");
oleg-shilo commented 1 year ago

Agree. Done. The change will be available in the very next release. Thank you for investigating it.