merken / Prise

A .NET Plugin Framework.
https://merken.github.io/Prise
MIT License
361 stars 39 forks source link

Dependency management question #54

Closed tinytownsoftware closed 1 year ago

tinytownsoftware commented 2 years ago

I am struggling with setting up a basic use case for our application. While the examples work easily enough, the problem is that most of our plugins have a number of dependencies, some of which are nuget packages hosted in our DevOps Artifacts in Azure. I looked at the Prise source code to see how it handled nupkg files and it's pretty clear that it only does a simple unzip and does not handle any kind of dependency resolution. Does this imply that any dependencies that the plugin has (all the way down the dependency chain) must be either referenced by the host or be part of the plugin assembly directory?

On a related note, the first time I attempted to run the project, I had the plugin dll in the directory by itself. Upon running the program, Prise told me that it could not load the plugin because Microsoft.Extensions.DependencyModel was missing. So I thought I'd just drop it into the plugin directory, but that did not work. I even tried adding an explicit nuget reference to the package and that did not work either. I verified that the dll is in the host's bin directory. I am running an Azure Function app. Here is the error:

Prise: Could not load file or assembly 'Microsoft.Extensions.DependencyModel, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
[2021-10-25T22:48:12.347Z] Evaluate failed:    at Prise.AssemblyLoading.DefaultPluginDependencyContextProvider.FromPluginLoadContext(IPluginLoadContext pluginLoadContext)
[2021-10-25T22:48:12.350Z]    at Prise.AssemblyLoading.DefaultAssemblyLoadContext.LoadPluginAssembly(IPluginLoadContext pluginLoadContext)
[2021-10-25T22:48:12.352Z]    at Prise.DefaultPluginLoader.LoadPlugin[T](AssemblyScanResult scanResult, String hostFramework, Action`1 configureLoadContext)
merken commented 1 year ago

Hi,

You'll need to copy all the files from the Nuget Package project, the easiest way to do this is to use the provided extensions (VS Code and Visual Studio): https://github.com/merken/Prise.VisualStudioExtensions/blob/7861b6998186938121d34afa2eabf38c1fabf877/src/prise-publishpluginextension/src/filehelper.ts#L27