Fix #2674 - Change the use of current directory to match the server assembly location

This will allow dependencies to be resolved beside the assembly as intended when startup scripts are used outside the working directory.
I am not sure why or how many people would do this, as TSAPI wont load plugins (existing issue), but this is a step in the direction of opening up to allow considerations for that.
This commit is contained in:
Luke 2022-10-06 20:24:41 +10:00
parent b48be1cf3b
commit c76b144b0a

View file

@ -42,7 +42,7 @@ Assembly? Default_Resolving(System.Runtime.Loader.AssemblyLoadContext arg1, Asse
if (arg2?.Name is null) return null; if (arg2?.Name is null) return null;
if (_cache.TryGetValue(arg2.Name, out Assembly? asm) && asm is not null) return asm; if (_cache.TryGetValue(arg2.Name, out Assembly? asm) && asm is not null) return asm;
var loc = Path.Combine(Environment.CurrentDirectory, "bin", arg2.Name + ".dll"); var loc = Path.Combine(AppContext.BaseDirectory, "bin", arg2.Name + ".dll");
if (File.Exists(loc)) if (File.Exists(loc))
asm = arg1.LoadFromAssemblyPath(loc); asm = arg1.LoadFromAssemblyPath(loc);