Local source of nuget packages doesn't exist
The package source is probably defined in %appdata%\nuget\nuget.config
. Edit this file in your favourite xml/text editor (VSCode perhaps?). You should see under a package sources element an add element that adds that file path. Comment out or delete that line.
If it's not in that file, try running dotnet restore --verbosity normal
or just dotnet restore -v n
. If you still only get an error message, try running dotnet new nugetconfig
, or temporarily create the C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
directory. NuGet, with normal verbosity, outputs the list of all nuget.config
files that were read. Open each one until you find which one defines the local source that does not exist, so you can edit it and remove it. Or just keep the empty directory.
It's also possible that the package source is defined in a MSBuild file, rather than a nuget.config
file. If that's the case, you might need to run dotnet msbuild -pp
to generate a pre-processed file (the msbuild with all imports evaluated to create a single, "stand-alone" msbuild file). You then search that file for the path that doesn't exist, then scroll up until you find a comment saying what file it was defined in. You then then choose whether you edit that file.
However, it may just be easier to create an empty directory at the path.
I had a similar error preventing nuget restore
command from working but with a different path:
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(132,5): error : The local source C:\work\nuget doesn't exist.
I fixed it by removing that path from:
Visual Studio ▶ Tools ▶ Options ▶ Nuget Package Manager ▶ Package Sources