Skip to content

Commit d8f58a0

Browse files
committed
Script files are executed in isolated assembly load context.
1 parent e710739 commit d8f58a0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,4 @@ project.json
265265
/build/dotnet-script
266266
/dotnet-script
267267
/.vscode
268+
/src/Dotnet.Script/Properties/launchSettings.json
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Reflection;
2+
using System.Runtime.Loader;
3+
4+
namespace Dotnet.Script
5+
{
6+
sealed class IsolatedAssemblyLoadContext : AssemblyLoadContext
7+
{
8+
protected override Assembly Load(AssemblyName assemblyName) => null;
9+
}
10+
}

src/Dotnet.Script/Program.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ private static int Wain(string[] args)
245245
packageSources.Values?.ToArray(),
246246
interactive.HasValue(),
247247
nocache.HasValue()
248-
);
248+
)
249+
{
250+
AssemblyLoadContext = new IsolatedAssemblyLoadContext()
251+
};
249252

250253
var fileCommand = new ExecuteScriptCommand(ScriptConsole.Default, logFactory);
251254
return await fileCommand.Run<int, CommandLineScriptGlobals>(fileCommandOptions);

0 commit comments

Comments
 (0)