Skip to content

Conversation

@jjw24
Copy link
Member

@jjw24 jjw24 commented Sep 21, 2020

Problem:
Currently in PluginLoader method, we are using AssemblyLoadContext.Default.LoadFromAssemblyPath to load plugin assembly dlls. The Default.LoadFromAssemblyPath loads assemblies into the default assembly load context and as a result the program looks for assembly dlls in the main application directory not in the plugin's own directory.

Consequently for an external plugin, in order for its dependent assembly to work you have to duplicate your assembly's PackageReference to the Flow.Launcher.Plugin library, or for default plugins you have to duplicate it with the main project:

image

Solution:

  1. Add a custom assembly loader for plugins and resolve any of the plugin's dependent assemblies to load from the plugin's own directory, or if the assembly exists with Flow.Launcher.Plugin then use the assembly there.

  2. Add Directory.Build.targets so default plugins will automatically make project reference to Flow.Launcher.Plugin not available for build.

  3. Use CopyLocalLockFileAssemblies=true in project file for both default and future external plugins so all referenced assemblies in the plugin are outputted and available for the main application to point to.

Result
Plugins no longer need to have the same package reference in Flow.Launcher.Plugin, duplicates can be removed and plugin assemblies are resolving correctly.

- For all plugin library projects we do not output referenced project assembly dll such as Flow.Launcher.Plugin
- Output all PackageReference dlls for plugins
if the assembly already referenced in Flow.Launcher.Plugin then ignore it
- since we have fixed how dependencies are resolved for plugins, these excess or duplicated package references can be safely removed

- for example Newtonsoft.Json can be removed from default plugins as it is included in Flow.Launcher.Plugin project, and external plugins will be resolved to use the reference there
@jjw24 jjw24 added the bug Something isn't working label Sep 21, 2020
@jjw24 jjw24 self-assigned this Sep 22, 2020
@jjw24
Copy link
Member Author

jjw24 commented Oct 25, 2020

TODO:
Version bump

Copy link
Member

@JohnTheGr8 JohnTheGr8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Apologies this took so long to look into... ;(

@JohnTheGr8 JohnTheGr8 merged commit e72407f into dev Nov 12, 2020
@JohnTheGr8 JohnTheGr8 deleted the fix_plugin_depenedency_loading branch November 12, 2020 10:39
@jjw24
Copy link
Member Author

jjw24 commented Nov 12, 2020

Awesome. Apologies this took so long to look into... ;(

All good bud :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants