diff --git a/BTCPayServer.Plugins.Test/Services/TestPluginService.cs b/BTCPayServer.Plugins.Test/Services/TestPluginService.cs
index f162ab826..aaabb31de 100644
--- a/BTCPayServer.Plugins.Test/Services/TestPluginService.cs
+++ b/BTCPayServer.Plugins.Test/Services/TestPluginService.cs
@@ -20,6 +20,7 @@ namespace BTCPayServer.Plugins.Test.Services
await using var context = _testPluginDbContextFactory.CreateContext();
await context.TestPluginRecords.AddAsync(new TestPluginData() {Timestamp = DateTimeOffset.UtcNow});
+ await context.SaveChangesAsync();
}
diff --git a/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml b/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml
index 3c761d54a..f1dd239f8 100644
--- a/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml
+++ b/BTCPayServer.Plugins.Test/Views/TestExtension/Index.cshtml
@@ -10,7 +10,7 @@
Persisted Data
The following is data persisted to the configured database but in an isolated DbContext. Every time you start BTCPayw with this plugin enabled, a timestamp is logged.
-
>
+
@foreach (var item in Model.Data)
{
- @item.Id at @item.Timestamp.ToString("F")
diff --git a/BTCPayServer/Plugins/PluginManager.cs b/BTCPayServer/Plugins/PluginManager.cs
index 2d557102a..70069d91c 100644
--- a/BTCPayServer/Plugins/PluginManager.cs
+++ b/BTCPayServer/Plugins/PluginManager.cs
@@ -25,6 +25,7 @@ namespace BTCPayServer.Plugins
private static readonly List _plugins = new List();
private static ILogger _logger;
+ private static List<(PluginLoader, Assembly, IFileProvider)> loadedPlugins;
public static bool IsExceptionByPlugin(Exception exception)
{
return _pluginAssemblies.Any(assembly => assembly?.FullName?.Contains(exception.Source!, StringComparison.OrdinalIgnoreCase) is true);
@@ -43,16 +44,24 @@ namespace BTCPayServer.Plugins
_logger.LogInformation($"Loading plugins from {pluginsFolder}");
Directory.CreateDirectory(pluginsFolder);
ExecuteCommands(pluginsFolder);
- List<(PluginLoader, Assembly, IFileProvider)> loadedPlugins =
- new List<(PluginLoader, Assembly, IFileProvider)>();
- var systemExtensions = GetDefaultLoadedPluginAssemblies();
- plugins.AddRange(systemExtensions.SelectMany(assembly =>
- GetAllPluginTypesFromAssembly(assembly).Select(GetPluginInstanceFromType)));
- foreach (IBTCPayServerPlugin btcPayServerExtension in plugins)
- {
- btcPayServerExtension.SystemPlugin = true;
- }
+ loadedPlugins = new List<(PluginLoader, Assembly, IFileProvider)>();
+ var systemPlugins = GetDefaultLoadedPluginAssemblies();
+ foreach (Assembly systemExtension in systemPlugins)
+ {
+ var detectedPlugins = GetAllPluginTypesFromAssembly(systemExtension).Select(GetPluginInstanceFromType);
+ if (!detectedPlugins.Any())
+ {
+ continue;
+
+ }
+ foreach (var btcPayServerPlugin in detectedPlugins)
+ {
+ btcPayServerPlugin.SystemPlugin = true;
+ loadedPlugins.Add((null,systemExtension, CreateEmbeddedFileProviderForAssembly(systemExtension)));
+ }
+ plugins.AddRange(detectedPlugins);
+ }
var orderFilePath = Path.Combine(pluginsFolder, "order");
var availableDirs = Directory.GetDirectories(pluginsFolder);
@@ -77,8 +86,6 @@ namespace BTCPayServer.Plugins
var disabledPlugins = GetDisabledPlugins(pluginsFolder);
-
-
foreach (var dir in orderedDirs)
{
var pluginName = Path.GetFileName(dir);
@@ -154,9 +161,7 @@ namespace BTCPayServer.Plugins
var webHostEnvironment = applicationBuilder.ApplicationServices.GetService();
List providers = new List() {webHostEnvironment.WebRootFileProvider};
- providers.AddRange(
- _pluginAssemblies
- .Select(CreateEmbeddedFileProviderForAssembly));
+ providers.AddRange(loadedPlugins.Select(tuple => tuple.Item3));
webHostEnvironment.WebRootFileProvider = new CompositeFileProvider(providers);
}