]> git.deb.at Git - rhonda/impostor.git/commitdiff
Automatically add ASP.NET Core to the library path (#507)
authorminiduikboot <mini@duikbo.at>
Fri, 20 Jan 2023 14:23:33 +0000 (15:23 +0100)
committerGitHub <noreply@github.com>
Fri, 20 Jan 2023 14:23:33 +0000 (15:23 +0100)
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 <kubastaron@hotmail.com>
src/Impostor.Server/Plugins/PluginLoader.cs

index 529cc169708e62e13943a569efb9ffd24919f6d7..76c10e65dad22e531b3005a4a85ed695d7a1b17c 100644 (file)
@@ -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"));