@@ -58,7 +58,7 @@ public class CodeDomEvaluator : EvaluatorBase<CodeDomEvaluator>, IEvaluator
5858 [ Obsolete ( "Starting from v4.10.0.0 compiling scripts on CS-Script own build server is no " +
5959 "longer recommended as using csc.exe native build server brings the same performance benefits " +
6060 "but without the cost of the custom build server. The default value of this field is also changed " +
61- "to 'false' for the same reason." ) ]
61+ "to 'false' for the same reason." , true ) ]
6262 public static bool CompileOnServer = false ;
6363
6464 /// <summary>
@@ -284,65 +284,66 @@ override protected (byte[] asm, byte[] pdb) Compile(string scriptText, string sc
284284
285285 if ( Runtime . IsCore )
286286 {
287- if ( CompileOnServer && Globals . BuildServerIsDeployed )
288- {
289- var usingCli = false ;
290- /////////////////////
291- if ( usingCli )
292- {
293- // using CLI app to send/receive sockets data
294-
295- // statr server; it will exit if it is already started
296- dotnet . RunAsync ( $ "\" { Globals . build_server } \" -start -port:{ BuildServer . serverPort } ") ;
297-
298- // send the buld request
299- cmd = $@ """{ Globals . build_server } "" -port:{ BuildServer . serverPort } csc { common_args . JoinBy ( " " ) } /out:""{ assembly } "" { refs_args . JoinBy ( " " ) } { source_args . JoinBy ( " " ) } ";
300- result . NativeCompilerReturnValue = dotnet . Run ( cmd , build_dir , x => result . Output . Add ( x ) ) ;
301- }
302- else
303- {
304- // using sockets directly
305- var request = $@ "csc { common_args . JoinBy ( " " ) } /out:""{ assembly } "" { refs_args . JoinBy ( " " ) } { source_args . JoinBy ( " " ) } "
306- . SplitCommandLine ( ) ;
307-
308- // ensure server running it will gracefully exit if another instance is running
309- var startBuildServerCommand = $@ """{ Globals . build_server } "" -listen -port:{ BuildServer . serverPort } -csc:""{ Globals . csc } """;
310-
311- dotnet.RunAsync(startBuildServerCommand);
312- Thread.Sleep(30);
313-
314- var response = BuildServer.SendBuildRequest(request, BuildServer.serverPort);
315-
316- bool buildServerNotRunning() => response.GetLines()
317- .FirstOrDefault()?
318- .Contains(" System. Net . Internals . SocketExceptionFactory + ExtendedSocketException")
319- == true ;
320-
321- for ( int i = 0 ; i < 10 && buildServerNotRunning ( ) ; i ++ )
322- {
323- Thread . Sleep ( 100 ) ;
324- response = BuildServer . SendBuildRequest ( request , BuildServer . serverPort ) ;
325- }
326-
327- if ( buildServerNotRunning ( ) )
328- {
329- throw new CompilerException ( $ "{ sdk_warning } CS-Script build server is not running:\n " +
330- $ "Either\n " +
331- $ " - start server from the host application 'CSScript.StartBuildServer();'\n " +
332- $ " - start server manually with 'dotnet { startBuildServerCommand } '\n " +
333- $ " - use RoslynEvaluator\n " +
334- $ " - compile script with CodeDom in the same process (`CodeDomEvaluator.CompileOnServer = false;`)") ;
335- }
336- result . NativeCompilerReturnValue = 0 ;
337- result . Output . AddRange ( response . GetLines ( ) ) ;
338- }
339- }
340- else
341- {
342- cmd = $@ """{ Globals . csc } "" { common_args . JoinBy ( " " ) } /out:""{ assembly } "" { refs_args . JoinBy ( " " ) } { source_args . JoinBy ( " " ) } ";
343-
344- result . NativeCompilerReturnValue = dotnet . Run ( cmd , build_dir , x => result . Output . Add ( x ) , x => std_err += x , CodeDomEvaluator . CscTimeout ) ;
345- }
287+ // should be deleted after the build server is removed v4.11.0+
288+ // if (CompileOnServer && Globals.BuildServerIsDeployed)
289+ // {
290+ // var usingCli = false;
291+ // /////////////////////
292+ // if (usingCli)
293+ // {
294+ // // using CLI app to send/receive sockets data
295+
296+ // // statr server; it will exit if it is already started
297+ // dotnet.RunAsync($"\"{Globals.build_server}\" -start -port:{BuildServer.serverPort}");
298+
299+ // // send the buld request
300+ // cmd = $@"""{Globals.build_server}"" -port:{BuildServer.serverPort} csc {common_args.JoinBy(" ")} /out:""{assembly}"" {refs_args.JoinBy(" ")} {source_args.JoinBy(" ")}";
301+ // result.NativeCompilerReturnValue = dotnet.Run(cmd, build_dir, x => result.Output.Add(x));
302+ // }
303+ // else
304+ // {
305+ // // using sockets directly
306+ // var request = $@"csc {common_args.JoinBy(" ")} /out:""{assembly}"" {refs_args.JoinBy(" ")} {source_args.JoinBy(" ")}"
307+ // .SplitCommandLine();
308+
309+ // // ensure server running it will gracefully exit if another instance is running
310+ // var startBuildServerCommand = $@"""{Globals.build_server}"" -listen -port:{BuildServer.serverPort} -csc:""{Globals.csc}""";
311+
312+ // dotnet.RunAsync(startBuildServerCommand);
313+ // Thread.Sleep(30);
314+
315+ // var response = BuildServer.SendBuildRequest(request, BuildServer.serverPort);
316+
317+ // bool buildServerNotRunning() => response.GetLines()
318+ // .FirstOrDefault()?
319+ // .Contains("System.Net.Internals.SocketExceptionFactory+ExtendedSocketException")
320+ // == true;
321+
322+ // for (int i = 0; i < 10 && buildServerNotRunning(); i++)
323+ // {
324+ // Thread.Sleep(100);
325+ // response = BuildServer.SendBuildRequest(request, BuildServer.serverPort);
326+ // }
327+
328+ // if (buildServerNotRunning())
329+ // {
330+ // throw new CompilerException($"{sdk_warning}CS-Script build server is not running:\n" +
331+ // $"Either\n" +
332+ // $" - start server from the host application 'CSScript.StartBuildServer();'\n" +
333+ // $" - start server manually with 'dotnet {startBuildServerCommand}'\n" +
334+ // $" - use RoslynEvaluator\n" +
335+ // $" - compile script with CodeDom in the same process (`CodeDomEvaluator.CompileOnServer = false;`)");
336+ // }
337+ // result.NativeCompilerReturnValue = 0;
338+ // result.Output.AddRange(response.GetLines());
339+ // }
340+ // }
341+ // else
342+ // {
343+ cmd = $@ """{ Globals . csc } "" { common_args . JoinBy ( " " ) } /out:""{ assembly } "" { refs_args . JoinBy ( " " ) } { source_args . JoinBy ( " " ) } ";
344+
345+ result . NativeCompilerReturnValue = dotnet . Run ( cmd , build_dir , x => result . Output . Add ( x ) , x => std_err += x , CodeDomEvaluator . CscTimeout ) ;
346+ // }
346347 }
347348 else
348349 {
0 commit comments