@@ -32,7 +32,14 @@ public async Task<TReturn> Run<TReturn, THost>(ExecuteScriptCommandOptions optio
3232 }
3333
3434 var pathToLibrary = GetLibrary ( options ) ;
35- return await ExecuteLibrary < TReturn > ( pathToLibrary , options . Arguments , options . NoCache ) ;
35+
36+ var libraryOptions = new ExecuteLibraryCommandOptions ( pathToLibrary , options . Arguments , options . NoCache )
37+ {
38+ #if NETCOREAPP
39+ AssemblyLoadContext = options . AssemblyLoadContext
40+ #endif
41+ } ;
42+ return await new ExecuteLibraryCommand ( _scriptConsole , _logFactory ) . Execute < TReturn > ( libraryOptions ) ;
3643 }
3744
3845 private async Task < TReturn > DownloadAndRunCode < TReturn > ( ExecuteScriptCommandOptions executeOptions )
@@ -57,7 +64,12 @@ private string GetLibrary(ExecuteScriptCommandOptions executeOptions)
5764 return pathToLibrary ;
5865 }
5966
60- var options = new PublishCommandOptions ( executeOptions . File , executionCacheFolder , "script" , PublishType . Library , executeOptions . OptimizationLevel , executeOptions . PackageSources , null , executeOptions . NoCache ) ;
67+ var options = new PublishCommandOptions ( executeOptions . File , executionCacheFolder , "script" , PublishType . Library , executeOptions . OptimizationLevel , executeOptions . PackageSources , null , executeOptions . NoCache )
68+ {
69+ #if NETCOREAPP
70+ AssemblyLoadContext = executeOptions . AssemblyLoadContext
71+ #endif
72+ } ;
6173 new PublishCommand ( _scriptConsole , _logFactory ) . Execute ( options ) ;
6274 if ( hash != null )
6375 {
@@ -124,11 +136,5 @@ public bool TryGetHash(string cacheFolder, out string hash)
124136 hash = File . ReadAllText ( pathToHashFile ) ;
125137 return true ;
126138 }
127-
128- private async Task < TReturn > ExecuteLibrary < TReturn > ( string pathToLibrary , string [ ] arguments , bool noCache )
129- {
130- var options = new ExecuteLibraryCommandOptions ( pathToLibrary , arguments , noCache ) ;
131- return await new ExecuteLibraryCommand ( _scriptConsole , _logFactory ) . Execute < TReturn > ( options ) ;
132- }
133139 }
134140}
0 commit comments