error NU1100: Unable to resolve 'Newtonsoft.Json (>= 13.0.4)' for 'net10.0'. PackageSourceMapping is enabled, the following source(s) were not considered: ... came, in this test, from a nuget.config whose <packageSourceMapping> section had no pattern matching the package. It failed only when the package had to be downloaded into an empty packages folder; the same restore passed while the package was already in the global packages folder. Add a pattern for the package under the source that should serve it.

In the test, one line, <package pattern="Newtonsoft.Json" /> under nuget.org, made the restore download the package and succeed. Map1 and pkgs are this test's own names. The commands on this page ran in cmd.

The error

dotnet restore --force --packages pkgs
  Determining projects to restore...
C:\...\cfg\Map1\Map1.csproj : error NU1100: Unable to resolve 'Newtonsoft.Json (>= 13.0.4)' for 'net10.0'. PackageSourceMapping is enabled, the following source(s) were not considered: C:\Program Files\dotnet\library-packs, nuget.org.
  Failed to restore C:\...\cfg\Map1\Map1.csproj (in 49 ms).
exit=1

The project path is shortened; nothing else changed. Note the first source in the list, C:\Program Files\dotnet\library-packs: it is not in this nuget.config, which starts with <clear />, yet the SDK still listed it as a source it did not consider.

Why it happens

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
  <packageSourceMapping>
    <packageSource key="nuget.org">
      <package pattern="Microsoft.*" />
    </packageSource>
  </packageSourceMapping>
</configuration>

The only pattern is Microsoft.*, and Newtonsoft.Json does not match it. The message says what followed: the mapping is enabled, and both sources were "not considered" for this package.

The error can hide on your own machine. The first restore of this project, without --packages, used the global packages folder, which already held Newtonsoft.Json 13.0.4, and passed:

dotnet restore --force
  Determining projects to restore...
  Restored C:\...\cfg\Map1\Map1.csproj (in 77 ms).
exit=0

Only when the package had to be downloaded, here into an empty pkgs folder of the project, did the mapping stop it. So the same mapping passed where the global folder already held the package and failed where the packages folder was empty; of the first two runs, only the one with the empty folder showed the mistake. A mapping written and tried on one machine with a full cache is not yet tested.

The fix

...
  <packageSourceMapping>
    <packageSource key="nuget.org">
      <package pattern="Microsoft.*" />
      <package pattern="Newtonsoft.Json" />
    </packageSource>
  </packageSourceMapping>
</configuration>
dotnet restore --force --packages pkgs
  Determining projects to restore...
  Restored C:\...\cfg\Map1\Map1.csproj (in 1.74 sec).
exit=0
dir /b pkgs
newtonsoft.json
exit=0

The pkgs folder now holds the package, fetched from nuget.org. Test a mapping change the same way, with an empty --packages folder: in this test the global packages folder made the broken mapping pass.

How it was reproduced

A console project from dotnet new console -f net10.0 with SDK 11.0.100 on Windows 11 and Newtonsoft.Json 13.0.4, and a nuget.config in the project folder with nuget.org and a mapping for Microsoft.* only. Three restores with --force: against the global packages folder (passed), into an empty pkgs folder (NU1100), and into it again after the pattern was added (passed, package downloaded). Every command shown without a PS> marker ran in cmd: a PowerShell script passed it as cmd /c ... 2>&1 and printed the exit= line after it.

Frequently asked

How do I fix NU1100 PackageSourceMapping is enabled the following sources were not considered?
Add a package pattern that matches the package id under the source that should serve it, in the packageSourceMapping section of nuget.config. In this test adding Newtonsoft.Json under nuget.org fixed the restore.
Why did the same restore pass in one run and fail with NU1100 in the other?
In this test the same mapping passed when the package was already in the global packages folder and failed with NU1100 when it had to be downloaded into an empty packages folder.
Why does NU1100 list library-packs as a source?
In this test the message listed C:\Program Files\dotnet\library-packs although the project nuget.config started with clear and named only nuget.org. It was listed among the sources not considered for the unmapped package.

More decoded errors in the Fixes category. For a source that cannot be reached at all, see NU1301.