docs/design/features/host-component-dependencies-resolution.md
This feature provides support for component dependency resolution. The planned usage is going to be implementing a managed public API which will provide a building block for custom AssemblyLoadContext implementation or for any other solution which needs to be able to resolve dependencies for a given component. In .NET Core the SDK produces .deps.json to describe component dependencies. The host already uses this during app startup to determine the list of static dependencies for the app itself. This new capability is to enable to use the same code/logic for resolving dependencies of dynamically accessed/loaded components.
The host components (mostly hostpolicy) already contain code which does .deps.json parsing and resolution for the app start, so to avoid code duplication and maintain consistent behavior the same code is used for component dependency resolution as well.
As of now the dependency resolution does NOT process frameworks. It only resolves dependencies directly described in the .deps.json of the component being processed.
For typical plugin scenarios resolving framework assemblies is not desirable, as the plugin will very likely want to share the framework with the app, and thus the ALC based on this component dependency resolution should fall back to the app for framework assemblies. Since there's no good way to detect which assembly is framework, it's better to not return them from the resolution for this scenario.
In the future it's possible expand the functionality to also support full framework resolution, but it should be an explicit choice (opt-in). The scenario for this would be using this feature to resolve dependencies for the MetadataLoadContext for inspection not loading. In which case it might make sense to load a full "app" using this functionality (including separate frameworks and so on).
Consequence of this is that we're not processing .runtimeconfig.json at all. For most cases this doesn't matter as typical classlib projects won't have .runtimeconfig.json generated by the SDK. Whenever the full framework resolution functionality is implemented, the feature would have to start processing .runtimeconfig.json as well.
This feature certainly provides a somewhat duplicate functionality to the existing DependencyModel. With several core differences though:
.deps.json format. It's not simple to use it for dependency resolution (although it's possible)..deps.json. The dependency resolution only handles runtime assets and only limits its view to the current RID.DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX - used just like in the appProgramFiles and ProgramFiles(x86") - used to find servicing root and the shared storeDOTNET_SHARED_STORE - used to find the shared store - just like the appDOTNET_MULTILEVEL_LOOKUP - used to enable multi-level lookup - used just like in the app.runtimeconfig.json or .runtimeconfig.dev.json. Most dynamically loaded components don't have these anyway, since SDK doesn't generate these for the classlib project type. The only meaningful piece of info from these which could be used is the set of probing paths to use. Currently the same set ofprobing paths as for the app is used. With the changes in .NET Core 3 where dotnet build will copy all static dependencies locally, the importance of additional probing paths should be very low anyway.dotnet build produced component won't work since self-contained apps typically have no probing paths (specifically they don't setup NuGet paths in any way)..deps.json. This is a different behavior from the app startup where these are considered. Is it important - needed?.deps.json the native library should be looked for in the component directory - thus requires probing - we can't figure out which of the files in the folder are native libraries in the hosts../foo/en-us/resource.dll we only take ./foo as the probing path. Consider using full paths instead - probably would require more parsing as we would have to be able to figure out the culture ID somewhere to build the true map AssemblyName->path in the managed class. Just like for native assets, if there's no .deps.json the only possible solution is to use probing, so the probing semantics would have to be supported anyway.