From 399e082b613b0d304a43b803611fdc4e015f8ed2 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 27 May 2023 14:01:16 -0500 Subject: [PATCH] add assembly resolver to help with more permissive plugin references to iw4madmin libraries --- Application/Main.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Application/Main.cs b/Application/Main.cs index 73ad77e95..24797f074 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -61,6 +61,19 @@ namespace IW4MAdmin.Application public static async Task Main(string[] args) { AppDomain.CurrentDomain.SetData("DataDirectory", Utilities.OperatingDirectory); + AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) => + { + var libraryName = eventArgs.Name.Split(",").First(); + + var overrides = new[] { nameof(SharedLibraryCore), nameof(Stats) }; + if (!overrides.Contains(libraryName)) + { + return AppDomain.CurrentDomain.GetAssemblies().First(asm => asm.FullName == eventArgs.Name); + } + // added to be a bit more permissive with plugin references + return AppDomain.CurrentDomain.GetAssemblies() + .FirstOrDefault(asm => asm.FullName?.StartsWith(libraryName) ?? false); + }; Console.OutputEncoding = Encoding.UTF8; Console.ForegroundColor = ConsoleColor.Gray; @@ -413,9 +426,9 @@ namespace IW4MAdmin.Application commandConfigHandler.BuildAsync().GetAwaiter().GetResult(); var appConfig = appConfigHandler.Configuration(); - var masterUri = Utilities.IsDevelopment + var masterUri = /*Utilities.IsDevelopment ? new Uri("http://127.0.0.1:8080") - : appConfig?.MasterUrl ?? new ApplicationConfiguration().MasterUrl; + : appConfig?.MasterUrl ?? */new ApplicationConfiguration().MasterUrl; var httpClient = new HttpClient { BaseAddress = masterUri,