Skip to content

AssemblyDependencyResolver uses probing paths from the app #3835

Closed

Description

@vitek-karas

The current implementation of AssemblyDependencyResolver which underneath is implemented in hostpolicy as corehost_resolve_component_dependencies currently uses the same probing paths as the app. This means that it gets the paths specified in .runtimeconfig.json, .runtimeconfig.dev.json and command line --additionalProbingPath.

The probing paths always include the app folder itself and by default for dotnet build the .runtimeconfig.dev.json includes NuGet caches in the paths.

This means that if we're trying to "load a plugin" using this API, if the plugin has a .deps.json record for asset lib.dll, but the file is missing from the plugin, we will search for it in the app as well as nuget cache and potentially other places.

Typically the resolution should fail in such cases (the plugin should behave as close to app as possible). Resolving the dependency from the app's directory is actually potentially dangerous as it may resolve to a wrong version.

AssemblyDependencyResolver is new in .NET Core 3.0 where the SDK will always copy all necessary references to the output, so the presence of NuGet caches in the .runtimeconfig.dev.json is not necessary - and in this case it's actually hurtful. If the dependency is resolved from NuGet cache (even if it's the right version), typically in the plugin scenario it will be loaded in isolation into the plugin's ALC. If the dependency was missing due to it being a "shared" dependency, this breaks the sharing contract and duplicate load occurs (same thing happens if it's resolved from the app folder as well).

The correct behavior for plugins would be to only resolve against probing paths which are not from the app. So the app path must be explicitly ignored. Also paths from .runtimeconfig.json and .runtimeconfig.dev.json for the app should probably be ignored as well (as those belong to the app).

It's sort of questionable if we should also ignore --additionalProbingPahts, but we probably should.

This would mean that plugins can't customize the probing paths - so we may consider either:

  • Supporting a new API on AssemblyDependencyResolver to add probing paths that way
  • Supporting parsing .runtimeconfig.json/.runtimeconfig.dev.json from the plugin itself and getting the paths from there
  • Potentially somehow using the app's probing paths, but avoiding the problem described above

Note that any change in this will be a breaking change against .NET 3.0.

This is related to potential SDK issues where non-private references do not correctly propagate into transitive dependencies. For example dotnet/sdk#1366.

Activity

  1. vitek-karas commented on Nov 11, 2019

    @vitek-karas
    MemberAuthor

    Related to this are doc issues dotnet/docs#15811 and dotnet/samples#1760 which try to address the overall scenario and the SDK behavior.

  2. transferred this issue fromdotnet/core-setupon Jan 30, 2020
  3. added this to the 5.0 milestone on Jan 30, 2020
  4. added
    untriaged
    on Feb 23, 2020
  5. removed
    untriaged
    on Feb 24, 2020
  6. modified the milestones: 5.0.0, 6.0.0 on Jul 13, 2020
  7. modified the milestones: 6.0.0, Future on Aug 2, 2021
  8. dotnet-policy-service commented on Feb 1, 2026

    @dotnet-policy-service
    Contributor

    Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

    This process is part of our issue cleanup automation.

  9. added
    backlog-cleanup-candidate
    on Feb 1, 2026
  10. dotnet-policy-service commented on Feb 16, 2026

    @dotnet-policy-service
    Contributor

    This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  11. removed this from the Future milestone on Feb 16, 2026
  12. locked and limited conversation to collaborators on Mar 18, 2026
  13. removed
    backlog-cleanup-candidate
    on Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions