Reputation: 865
After opened the project in another computer and run it on VS Code, the following problem occurred:
C:\Program Files\dotnet\sdk\2.2.300\NuGet.targets(121,5): error : The
local source C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'
doesn't exist.
I found the solution for the VS but no VS Code.
Upvotes: 70
Views: 88081
Reputation: 11
Firstly I faced the issue when I cloned the MAUI repo from GitHub and tried to run it.
The error was
The local source '/Users/david ortinau/work/Localstorage' doesn't exist.
What I did was just delete the NuGet.Config
which automatically reinitialized the nuggets. and Issue solved.
Upvotes: 1
Reputation: 53
Check your Registered Nuget Sources. You can do it by running this command:
dotnet nuget list source
If some of the sources is missing or wrong you have to remove it:
dotnet nuget remove source "Your Package Source Name"
Upvotes: 0
Reputation: 25553
I was getting the following error.
error NU1301: The local source 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages' doesn't exist.
Earlier I accidentally deleted the entire shared folder itself( drive was full, so was cleaning up) and so the error.
After reading the @zivkan's answer at the top, I created a file by name NuGetPackages. But that did not solve the problem, because we need to create a folder(directory), not file. So after creating a directory, by name NuGetPackages, dotnet restore worked again.
Of course you need admin permission to create that folder.
Upvotes: 1
Reputation: 17145
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
On macOS and Linux you may delete ~/.nuget
Upvotes: 44
Reputation: 1372
Although the error seems not to be related to nuget, it is actually related.
Open PowerShell and run the following command:
dotnet new nugetconfig
Upvotes: 9
Reputation: 152
I had trouble understanding the answers, maybe some of them had the solution. What helped me in the end:
I edited C:\Windows\System32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
and removed <packageSources> with the value "..\NuGet.Config"
Not sure how it got there, the actual value might be different for everyone.
Upvotes: 1
Reputation: 351
I have used more visual method for resolving this issue look 👇
✍edit1: Possible reason, your project may have offline packages referenced to your very first computer. And than, when you go trough another computer, it cant recognise the local source path of your offline packages.
Upvotes: 11
Reputation: 331
Open a PowerShell window and enter the following code: dotnet new nugetconfig
Upvotes: 18
Reputation: 1062
Because the message says that the folder doesn't exist, I created it, and the problem disappeared. Yes, it was so simple like that.
BTW there is a discussion on GitHub on similar trouble, and Rob Relya from Microsoft wrote:
This is by design behavior. We fail restore if any of your sources are not reachable. We don't want to create a folder for you, in case it was a typo.
From my point of view, it's OK.
Upvotes: 3
Reputation: 1
I was upgrading my dontet MVC project from .Net core 2.2 to 3.1 and adding a reference to the Microsoft.Extensions.Configuration.AzureAppConfiguration. when I had this issue. All I did is removed the "add key="Local" value=".References" from nuget.config and the issue is solved. I was able to reference the package,
Upvotes: 0
Reputation: 327
I also had the same issue on DevOps (image 1,2) .net core restore task. I resolved this by just removing the Offline package reference (image 3) from the NuGet.config file.
Upvotes: 1
Reputation: 15091
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.
Upvotes: 117