Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nuget error: the path for the selected source could not be resolved

Nuget in Visual studio can't access a custom package source location on a shared network drive. I am able to browse the nuget.org and microsoft packages just fine. I just can't browse the local network share we have setup for custom nuget packages. When I try I get the error:

the path '\\someserver\somefolder' for the selected source could not be resolved

I am able to access the file location through explorer and a mapped drive. I tried removing and re-adding the network location in nuget package manager, but when I try to re-add it, I can't see the mapped network drive or use the full unc path (it throws error that the network location doesn't exist).

like image 773
goku_da_master Avatar asked May 19 '16 17:05

goku_da_master


People also ask

What is NuGet package source URL?

The default source is nuget.org, which has the following package source URL: https://api.nuget.org/v3/index.json .

How do I install a NuGet package in PowerShell?

Open PowerShell as administrator. Run the command Install-Module PowerShellGet -Force to install the NuGet package. When asked for confirmation to install the NuGet provider, press the Y key and press Enter .


2 Answers

Finally!... the answer!

The problem was running visual studio as administrator.

The network share nuget was trying to access required my own user credentials, but running visual studio as administrator uses the local administrator credentials which didn't have access to the share.

There are a few ways to prevent VS from running as administrator (ex: if you're using a shortcut you need to go to properties and uncheck "run as administrator"), but since I had ran the compatibility troubleshooter on devenv.exe to force it to always run as admin, I didn't know how to undo it. This link shows you how to do that:

https://superuser.com/a/547846/213179

Note: to see other reasons why not to run visual studio as administrator, read the posted question in the above link:

"For those interested, the reason I want to go back is because some features (such as drag-and-drop files into VS, open files from Windows Explorer, etc.) no longer work."

like image 187
goku_da_master Avatar answered Nov 14 '22 22:11

goku_da_master


Package Source must be given as wrong path. Try this

  • Go to references
  • Right and Click on Manage Nu-get Packages
  • On the top right you will see Package Source
  • Package Source drop down will have a settings button over there
  • Remove available packages
  • In Machine wide package, tick Microsoft and .Net
  • Remove available source package if the directory does not exist
like image 34
Tino Jose Thannippara Avatar answered Nov 14 '22 22:11

Tino Jose Thannippara