CorePluginLoader 0.1.0

dotnet add package CorePluginLoader --version 0.1.0
                    
NuGet\Install-Package CorePluginLoader -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CorePluginLoader" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CorePluginLoader" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CorePluginLoader" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CorePluginLoader --version 0.1.0
                    
#r "nuget: CorePluginLoader, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CorePluginLoader@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CorePluginLoader&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CorePluginLoader&version=0.1.0
                    
Install as a Cake Tool

CorePluginLoader

As some know .net core has some problems solving dependencies on dynamically loaded libraries, this project provides a simple API for loading plugins and their dependencies. This project does NOT isolate the libraries of the main project, in case you are looking for libraries loader that isolates the libraries of the main project I advise to look at the project .NET Core Plugins

The motivation for development was to make it easier to add plugins to the project when they are still in the initial development phase or need to be done quickly, the library facilitates loading by automatically managing everything when possible.

Getting started

You can either install the library via NuGet or compile the library manually.

var pluginLoader = new PluginLoader<T>();
var plugins = pluginLoader.LoadPlugin(assemblyFileName: "./Plugins/MyPlugin/MyPlugin.dll");
  • T: Plugin class or interface type
  • assemblyFileName: Path to the assembly DLL file

See examples of projects in Examples/

Usage

To make use of plugins you need at least two projects

  1. The Host that loads the plugins
  2. The Plugin

Usually a third abstraction project is used for the interaction between the Host and the Plugin, but this project focuses on the memory sharing between the Plugin and the Host. That's because I want to allow a plugin to call methods, get types, and so on, from other plugins. If the memory were isolated for each plugin this would not be possible in an easy way.

Host

Program.cs

using System;
using System.IO;
using CorePluginLoader;

namespace HostApplication {
    public class Program {
        public static void Main(string[] args) {
            // Set plugins directory
            var pluginsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Plugins/");
            // Create plugin loader
            var pluginLoader = new PluginLoader<IPlugin>();
            // Load plugins
            var pluginsInstances = pluginLoader.LoadPlugins(Directory.GetFiles(pluginsDirectory, "*.dll", SearchOption.AllDirectories));
            // Show loaded plugins
            foreach (var plugin in pluginsInstances) {
                Console.WriteLine($"Plugin loaded: {plugin.PluginName}");   
            }
            Console.ReadKey();
        }
    }
}

IPlugin.cs

namespace HostApplication {
    public interface IPlugin {
        string PluginName { get; }
    }
}

Plugins

Plugin.cs

using HostApplication;

namespace Plugin {
    public class Plugin : IPlugin {
        public string PluginName => "MyPlugin";
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.2

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 828 5/19/2019