Repository navigation
Fix the plugin references to work with packages - #16799
Merged
Merged
Conversation
For plugins to correctly reference other projects they need to specify both Private=false and ExcludeAssets=runtime so that it works for both project and package references.
mairaw
reviewed
Jan 24, 2020
mairaw
reviewed
Jan 24, 2020
jkoritzinsky
approved these changes
Jan 24, 2020
elinor-fung
approved these changes
Jan 24, 2020
Co-Authored-By: Maira Wenzel <[email protected]>
tdykstra
reviewed
Jan 24, 2020
tdykstra
left a comment
Contributor
There was a problem hiding this comment.
LGTM except for one question.
| The `<Private>false</Private>` element is important. This tells MSBuild to not copy *PluginBase.dll* to the output directory for HelloPlugin. If the *PluginBase.dll* assembly is present in the output directory, `PluginLoadContext` will find the assembly there and load it when it loads the *HelloPlugin.dll* assembly. At this point, the `HelloPlugin.HelloCommand` type will implement the `ICommand` interface from the *PluginBase.dll* in the output directory of the `HelloPlugin` project, not the `ICommand` interface that is loaded into the default load context. Since the runtime sees these two types as different types from different assemblies, the `AppWithPlugin.Program.CreateCommands` method won't find the commands. As a result, the `<Private>false</Private>` metadata is required for the reference to the assembly containing the plugin interfaces. | ||
|
|
||
| Now that the `HelloPlugin` project is complete, we should update the `AppWithPlugin` project to know where the `HelloPlugin` plugin can be found. After the `// Paths to plugins to load` comment, add `@"HelloPlugin\bin\Debug\netcoreapp3.0\HelloPlugin.dll"` as an element of the `pluginPaths` array. | ||
| Similarly, the `<ExcludeAssets>runtime</ExcludeAssets>` element is also important if the `PluginBase` references other packages. This setting has the same effect as `<Private>false</Private>` but works on package references in the transitive closure of dependencies of the `PluginBase` project. |
Contributor
There was a problem hiding this comment.
Can we expect the intended audience of this article to be familiar with the phrase "transitive closure of dependencies"? If not, a brief explanation might be helpful.
Member
Author
There was a problem hiding this comment.
Good point - I changed the wording - hopefully it's easier to understand now.
tdykstra
approved these changes
Jan 24, 2020
Co-Authored-By: Tom Dykstra <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
For plugins to correctly reference other projects they need to specify both Private=false and ExcludeAssets=runtime so that it works for both project and package references.
Fixes #15811