Skip to content
Latchkey

NuGet packageSourceMapping "no source defines the pattern" in CI

When packageSourceMapping is enabled, a package only restores from sources whose patterns match its id. If no pattern matches, NuGet refuses to look at any source and restore fails even though the package exists.

What this error means

restore fails to find a package that is clearly on a feed, because the packageSourceMapping section has no pattern covering that id, so no source is allowed to serve it.

dotnet
error NU1100: Unable to resolve 'Contoso.Internal (>= 1.0.0)' for 'net8.0'.
      PackageSourceMapping is enabled, the following source(s) were not considered:
      private (no matching package pattern for Contoso.Internal).

Common causes

No mapping pattern matches the package id

Source mapping restricts each source to declared id patterns. A package whose id matches no pattern is served by no source.

A new package added without updating the mapping

You referenced a new internal package but did not add its id (or a prefix) to the private source mapping.

How to fix it

Add a matching pattern to the source

  1. Identify which feed hosts the package.
  2. Add a packageSource entry with a pattern that matches the id or its prefix.
  3. Restore again so the mapping allows that source.
nuget.config
<packageSourceMapping>
  <packageSource key="private">
    <package pattern="Contoso.*" />
  </packageSource>
  <packageSource key="nuget.org">
    <package pattern="*" />
  </packageSource>
</packageSourceMapping>

Verify prefixes cover all internal ids

Use a prefix pattern like Contoso.* so new internal packages under that namespace resolve without editing the mapping each time.

How to prevent it

  • Map private feeds with prefix patterns that cover your namespaces.
  • Update packageSourceMapping whenever a new id namespace appears.
  • Keep a * mapping to nuget.org for public packages.

Frequently asked questions

What causes ""package source mapping""?
Source mapping restricts each source to declared id patterns. A package whose id matches no pattern is served by no source.
How do I fix "package source mapping"?
Add a matching pattern to the source

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card