Skip to content

How should optional dependencies (plugins) work with deps.json? #15233

@kendfrey

Description

@kendfrey

Summary

We have an application referencing many libraries which are considered optional, and are only used as MEF plugins. Currently if one of these dlls is missing at runtime, the application fails to start with an error like "An assembly specified in the application dependencies manifest (MyApp.deps.json) was not found". We would like to deploy copies of our application with a subset of these plugins, but this error prevents that. What do we need to do to ignore missing dependencies?

Details

Our MyApp solution contains the following projects:

  • Core (library)
  • MyApp (executable)
  • PluginA (library)
  • PluginB (library)
  • etc.

The MyApp projects has references to all the Plugin libraries. All projects reference the Core library.

MyApp is considered a complete package, containing the "base" application (MyApp.exe) as well as a standard set of plugins (PluginA.dll, etc.). Plugins provide the business logic powering MyApp, and are loaded using MEF. The plugins and the base application are developed together with tight collaboration. We license the plugins to clients on a per-plugin basis.

The reason MyApp references its plugins is so that dotnet works seamlessly when running and publishing the application. Developers working on a plugin can set MyApp as their startup project, and pressing F5 in Visual Studio automatically builds the plugin and starts the application without requiring any extra build steps. Publishing the application is just one command, instead of publishing each plugin individually. This is why we have chosen to reference plugins from the base application, when there are no "real" dependencies.

We wish to remove any unlicensed plugins when a client downloads a release. Currently all plugins must remain in the application directory, because MyApp.deps.json requires them. Our current workaround is to disable plugins based on licensing information. This causes a potential problem, as clients may find a way to re-enable disabled plugins, and gain access to unlicensed features. This is why we want to completely remove unlicensed plugins.

The only feasible solution we've found is to modify the deps.json file generated by dotnet and remove the references to the plugins, so that the application can start without them. This is not a good solution, as it abuses dotnet infrastructure and may become brittle. What is the correct solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedRequest triage from a team member

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions