natemcmaster / DotNetCorePlugins

.NET Core library for dynamically loading code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I load a plugin and it's dependencies from a local NuGet cache

Valks opened this issue · comments

Is it possible to use a local path i.e. AppData as a NuGet Cache for plugins to restore dependencies from?

I've come up with a way (with some help from the internet) to parse a NuGet package and its dependencies (while filtering out the system runtime, etc.) and extract them into a folder, i.e.

image

From that point, I want to load the SamplePlugin and have the PluginLoader resolve its dependencies based on the content in the Cache folder (or the local NuGet store if they already have it cached).

To load the plugin I can brute force my way to the dll (side question: is there a better option?) but that won't do any good with the dependencies.

An option I have is to copy all the dll's to a common folder but I'm not sure how well that'll go with native dependencies or resolving the correct target framework.

Another option I can think of is to try and install the dependencies into the local user store but I'd prefer not to touch those files.

Any help or thoughts would be greatly appreciated.

For now, going to drop this because I don't have the time to work on it. Instead, I've just created the expected answer of making the plugin publish, zip the output and extract that to a cache folder which is then loaded at runtime.

Still, if I get a chance I'll give it another go but it's probably best the dependencies are inside the plugin package because that ensures the expected dependencies are loaded.