Adding this in 2024 as a new answer (VS 2022, .NET 8/9 etc). It is possible that you have a packageSourceMapping
element in your global NuGet.config
causing this behavior.
I'm unsure how this element was added in my case, as the NU1100 error appeared globally while I was working on a project, where between builds it suddenly started throwing the NU1100 errors. Reverting changes had no effect.
The offending element may look something like this:
<packageSourceMapping>
<packageSource key="Local">
<package pattern="Lula.Extensions.Xunit" />
</packageSource>
</packageSourceMapping>
The NU1100 error you get includes
the following source(s) were not considered: [...] nuget.org.
Full erroneous "default" config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
<packageSourceMapping>
<packageSource key="Local">
<package pattern="Lula.Extensions.Xunit" />
</packageSource>
</packageSourceMapping>
</configuration>
Fixed, proper default config
Using a config like the following should allow dotnet restore
to work normally again. Note that you may have more legitimate package sources, but you shouldn't have a packageSourceMapping
like above.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>