Modular Startup Load Assembly from folder

It is possible to configure modular startup to scan assembly in a folder and load module from it?
Thanks Gianmaria

You’ll need to load all Assemblies, then you can pass those assemblies to the ModularStartup constructor.

Our web/app tools does this to load plugins from the /plugins folder.

Relevant code:

var assemblies = new List<Assembly>();
var pluginsDir = vfs .GetDirectory("plugins");
if (pluginsDir != null)
{
    var plugins = pluginsDir.GetFiles();
    foreach (var plugin in plugins)
    {
        if (plugin.Extension != "dll" && plugin.Extension != "exe")
            continue;

        var dllBytes = plugin.ReadAllBytes();
        $"Loading '{plugin.VirtualPath}', size: {dllBytes.Length} bytes".Print();
        var asm = Assembly.Load(dllBytes);
        assemblies.Add(asm);
    }
}

Then pass assemblies.ToArray() to the ModularStartup constructor.