11
11
using System . IO ;
12
12
using System . Linq ;
13
13
using System . Runtime . InteropServices ;
14
+ using System . Runtime . Loader ;
14
15
using System . Threading . Tasks ;
15
16
16
17
namespace Dotnet . Script
@@ -247,7 +248,7 @@ private static int Wain(string[] args)
247
248
nocache . HasValue ( )
248
249
)
249
250
{
250
- AssemblyLoadContext = new ScriptAssemblyLoadContext ( )
251
+ AssemblyLoadContext = CreateAssemblyLoadContext ( )
251
252
} ;
252
253
253
254
var fileCommand = new ExecuteScriptCommand ( ScriptConsole . Default , logFactory ) ;
@@ -265,16 +266,24 @@ private static int Wain(string[] args)
265
266
266
267
private static async Task < int > RunInteractive ( bool useRestoreCache , LogFactory logFactory , string [ ] packageSources )
267
268
{
268
- var options = new ExecuteInteractiveCommandOptions ( null , Array . Empty < string > ( ) , packageSources ) ;
269
+ var options = new ExecuteInteractiveCommandOptions ( null , Array . Empty < string > ( ) , packageSources )
270
+ {
271
+ AssemblyLoadContext = CreateAssemblyLoadContext ( )
272
+ } ;
269
273
await new ExecuteInteractiveCommand ( ScriptConsole . Default , logFactory ) . Execute ( options ) ;
270
274
return 0 ;
271
275
}
272
276
273
277
private async static Task < int > RunInteractiveWithSeed ( string file , LogFactory logFactory , string [ ] arguments , string [ ] packageSources )
274
278
{
275
- var options = new ExecuteInteractiveCommandOptions ( new ScriptFile ( file ) , arguments , packageSources ) ;
279
+ var options = new ExecuteInteractiveCommandOptions ( new ScriptFile ( file ) , arguments , packageSources )
280
+ {
281
+ AssemblyLoadContext = CreateAssemblyLoadContext ( )
282
+ } ;
276
283
await new ExecuteInteractiveCommand ( ScriptConsole . Default , logFactory ) . Execute ( options ) ;
277
284
return 0 ;
278
285
}
286
+
287
+ static AssemblyLoadContext CreateAssemblyLoadContext ( ) => new ScriptAssemblyLoadContext ( ) ;
279
288
}
280
289
}
0 commit comments