From: miniduikboot Date: Fri, 20 Jan 2023 14:23:33 +0000 (+0100) Subject: Automatically add ASP.NET Core to the library path (#507) X-Git-Tag: v1.8.1~6 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=97390a088257dfbba3b8d7994f821b6f8665d35c;p=rhonda%2Fimpostor.git Automatically add ASP.NET Core to the library path (#507) Currently Impostor.Http is becoming an almost mandatory plugin. Because it depends on ASP.Net, many people who fail to add the required path to their config will run into an error. Help them by automatically adding ASP.NET Core. Also .NET updates every now and then and updating the version number in the config.json is annoying me. This commit uses the fact that ASP.NET Core DLL's are in a sibling folder to the .NET runtime and should therefore work on most setups unless they've installed ASP.NET Core in a very weird way. * Fix casing Co-authored-by: js6pak --- diff --git a/src/Impostor.Server/Plugins/PluginLoader.cs b/src/Impostor.Server/Plugins/PluginLoader.cs index 529cc16..76c10e6 100644 --- a/src/Impostor.Server/Plugins/PluginLoader.cs +++ b/src/Impostor.Server/Plugins/PluginLoader.cs @@ -27,6 +27,19 @@ namespace Impostor.Server.Plugins CheckPaths(pluginPaths); CheckPaths(libraryPaths); + // Add library path for ASP.NET Core. This is useful for plugins that depend on ASP.NET Core, + // like Impostor.Http. The path contains the .NET version number, so it changes regularly. + var aspNetPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + .Replace("Microsoft.NETCore.App", "Microsoft.AspNetCore.App"); + if (Directory.Exists(aspNetPath)) + { + libraryPaths.Add(aspNetPath); + } + else + { + Logger.Information("ASP.NET Core not installed, this may cause issues if you have plugins that depend on it"); + } + var rootFolder = Directory.GetCurrentDirectory(); pluginPaths.Add(Path.Combine(rootFolder, "plugins"));