natemcmaster / DotNetCorePlugins

.NET Core library for dynamically loading code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] By using Shared Types can we skip using <private> and <excludeassets>

dferretti opened this issue · comments

Following the recommendations here: https://docs.microsoft.com/en-gb/dotnet/core/tutorials/creating-app-with-plugin-support
It mentions that a plugin should reference the plugin base/abstractions project and include <Private>false</Private> and <ExcludeAssets>runtime</ExcludeAssets> to keep the plugin from holding its own duplicate copy of the types defined in PluginBase. The samples they provide such as this one https://github.com/dotnet/samples/blob/f0e5dc7cfdf88a03ef1517c33544c46831cdf143/core/extensions/AppWithPlugin/JsonPlugin/JsonPlugin.csproj do the same.

I know your library abstracts and hides much of the difficulty in getting assembly loading to work correctly - is this one of those things it smooths over as well? Are we safe to just use regular ProjectReferences and PackageReferences without specifying those other options, as long as we indicate which SharedTypes to use?

The samples here https://github.com/natemcmaster/DotNetCorePlugins/blob/84028845c24a8ca8b6cfda245154dfc7ef32e60b/samples/hello-world/MyPlugin/MyPlugin.csproj and our own tests seem to work fine, but I would just like to be sure.

This project doesn't do anything with the MSBuild project to manipulate which .dll files will get published. If you want to optimize for fewer files, you should use the <private> and <excludeassets> tags in your .csproj file. As long as the .dll you are excluding come from the host, I don't expect this will impact your application other than removing a few unused files from your plugin.

Gotcha that makes sense - thanks!