Skip to main content

resolve_with_context

Function resolve_with_context 

Source
pub fn resolve_with_context(
    manifest_dir: &Path,
    config_cache: &NuGetConfigCache,
    policy: &RegistryAccessPolicy,
    user_profile_config: Option<&Path>,
    user_profile_sources: &AtomicBool,
) -> NuGetConfig
Expand description

Resolves manifest_dir’s in-repo NuGet.Config ancestor chain, plus the user-profile tier (issue #561), into a merged NuGetConfig (FR-001/FR-002, C1’s root-to-leaf accumulation).

The form NuGetEcosystem::parse_manifest calls, threading NuGetParseContext’s user_profile_config/user_profile_sources fields through.

§Credential half vs. routing half (§3.8, FR-005/FR-006)

A ConfigTier::UserProfile file’s contribution splits into two halves:

  • Credential half — always applied, regardless of user_profile_sources: credentialed_keys, the §3.4 credential-suppression set (from its own <disabledPackageSources>), its raw <packageSourceCredentials> values, and user_profile_add (its own <clear/>/<add>/<remove> batch, tracked separately from the shared sources routing state).
  • Routing half — skipped entirely when user_profile_sources is false: sources, sources_cleared, removed/nuget_org_removed, disabled, mapping — all six, together. With the flag off, a user-profile file’s <clear/>/<remove>/ <disabledPackageSources>/<packageSourceMapping> reach no project at all (NFR-005).

A repo-tier file’s contribution is unaffected by user_profile_sources and always applies in full — byte-identical to spec 035.

§Credential binding (§3.2, FR-007)

The final pass, in bind_credentials_and_finalize, binds a user-profile credential to a resolved entry E iff all of: (0) E.key does not overlap the credential-suppression set (union, exclusion); (1) exactly one user-profile credential’s key-candidates overlap E.key; (2) exactly one user_profile_add entry’s key-candidates overlap that credential’s own key; (3) E’s URL equals user_profile_add’s URL, by normalized full-URL string equality (not origin equality — see §3.2’s rationale). Any credential-key match on E failing any condition fails E closed as HasCredentials, except the FR-008 public-index carve-out. Repo-tier <packageSourceCredentials> (FR-004) is checked first and wins unconditionally, independent of any C2 outcome.