The source at nuget.org is unreachable? - c#

I'm trying to install SignalR in my C# project, but all I get when running install-package Microsoft.AspNet.SignalR is:
The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache(...)
At line:1 char:1
+ install-package Microsoft.AspNet.SignalR
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
This error was posted to Stack Overflow a few times, but no solution has worked for me. I've tried:
Starting a new project
Removing and adding all of my nuget sources
Trying nuget with projects where it worked
Reinstalling nuget
Reinstalling Visual Studio
Nothing worked. I can reach nuget.org just fine from my browser.
I would appreciate some help.

Try using the UI. For me the UI works fine but the Package Manager needs to be told explicitly where the source is. Try the command:
install-package Microsoft.AspNet.SignalR -Source nuget.org

To work around this, you can run nuget install Microsoft.AspNet from the command line in your solution root. Then when you try again in the Package Manager it will find the cached copy and succeed:
.nuget\NuGet.exe install Microsoft.AspNet.SignalR.Client -OutputDirectory packages

Related

Nuget misbehaving with newtonsoft.json package

Why Nuget producing an error when I install a package after Newtonsoft.Json v11.0.2 is installed. Whenever I try to install another package I get the following error
Install-Package : An error occurred while retrieving package metadata for 'Newtonsoft.Json.11.0.2'
from source 'C:\Users\yusuf\Documents\Visual Studio 2015\Projects\Eman\packages'.
At line:1 char:1
+ Install-Package MaterialDesignThemes
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.
InstallPackageCommand
Whenever i remove the line with the Newtonsoft.json package defined in packages.config the package installs successfully. Is it something wrong with json package itself or is it my package manager that's messed up, anyway can someone show me how i can fix this.
P.S. This happens with whichever package i try to install while json package is already installed.
EDIT I tried deleting the package line in packages.config and also deleting the downloaded package files and reinstalled the package several times, i keep getting the same problem
First, downgrade Newtonsoft.Json v11.0.2 to Newtonsoft.Json v6.0.4. Second, install another nuget package.
If the package successfully installs, upgrade Newtonsoft.Json v6.0.4 back to Newtonsoft.Json v11.0.2.

Visual Studio 2015 "nuget" issue?

I've been trying to install a NuGet package on Visual Studio, but I've been getting an error. When I install Discord.Net on the package manager, it said it worked, but I don't get the package. However, when I use the console I get an error. Here's what I get (this is about in the middle of the output highlighted in yellow):
Successfully installed 'RestSharp 105.2.3' to Userbot
Install failed. Rolling back...
Package 'WebSocket4Net.0.14.1' does not exist in project 'Userbot'
Removed package 'RestSharp.105.2.3' from 'packages.config'
Removed package 'Nito.AsyncEx.3.0.1' from 'packages.config'
Removed package 'Newtonsoft.Json.8.0.3' from 'packages.config'
Package 'WebSocket4Net.0.14.1' does not exist in folder
'C:\Users\Josh\documents\visual studio 2015\Projects\Userbot\packages'
Then here's a message at the end highlighted in red:
Install-Package : Could not find file
'C:\Users\Josh\.nuget\packages\websocket4net\0.14.1\websocket4net.0.14.1.nupkg'.
At line:1 char:1
+ Install-Package Discord.Net
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
And that's the end of the package. And here's the weird part, other packages install fine.
Does anyone know the issue?
Thanks,
Josh

Nuget: Failed to add reference to 'EntityFramework'

I tried to update a few packages using Package Manager Console, but I am getting this:
update-package : Failed to add reference to 'EntityFramework'.
At line:1 char:1
+ update-package EntityFramework -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
Here are a few commands that I tried:
Install-Package EntityFramework
Update-Package EntityFramework -Reinstall
Update-Package -Reinstall
I also tried to update packages using UI and ran VS in administrator mode. Important to mention, the project is under TFS source control (I did make it work when I removed TFS binding). There are a few other packages - same thing with them. I see yellow exclamation next to references and I can't re-install packages.
I've never seen this error before, similar question answers don't work for me.
In my case packages where checked in TFS source control (which is of course terrible). This answer explains how to setup ignore rules for TFS. After deleting packages everything was fixed.
I've tried your commands on one of my project that under VSTS source control, no issue occurred (VS 2015.3 + Package Manager Console Host Version 3.5.0.1484). You may try the items below:
Check Package Manager Console version to see whether it is the latest version.
Try to open the package from Manage Nuget Packages, uninstall the EntityFramework package and re-install it:
Enable Package restore in VS:

'System.Net.Http' already has a dependency defined for 'System.Runtime'

I'm trying to install the MaxMind MinFraud package via NuGet. Whenever I try, I get the following back -
PM> install-package MaxMind.MinFraud
Attempting to resolve dependency 'System.Net.Http (≥ 4.0.0)'.
install-package : 'System.Net.Http' already has a dependency defined for 'System.Runtime'.
At line:1 char:1
+ install-package MaxMind.MinFraud
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
A few other similar questions here suggested restarting VS, manually adding a reference to System.Net.Http and clearing NuGet Package Cache, and changing the target framework to 4.6.2 (originally 4.5), all of which did not work for me.
Any ideas on what I can try next?
I installed this package successful in my Visual Studio 2015 Update 3 project with NuGet Package Manager 3.4.4.
So please make sure your are using the latest version of Visual Studio 2015 and NuGet Package Manager.

Issue when installing DiscordSharp NuGet Package

I have resolved this issue, please see the answer I posted
I am having an issue when I try to install DiscordSharp (Github | NuGet) using the Package Manager Console.
When I use the install command as shown on the Discord Sharp NuGet page I get the following error (sorry about the formatting see my comment for a screenshot of the error):
PM> Install-Package DiscordSharp -Pre
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.0)'.
Install-Package : The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd' has invalid child element 'developmentDependency' in namespace
'http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd'. List of possible elements expected: 'copyright, tags, description, frameworkAssemblies,
references, dependencies, releaseNotes, language, summary' in namespace
'http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd'.
At line:1 char:1
+ Install-Package DiscordSharp -Pre
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
This is the error I get in a new project before installing any other packages, and I get the same error after installing json.net before DiscordSharp.
If it helps I am using Visual Studio 2012 on Windows 8.
If there is anything I have missed in the post which is needed, please let me know. Thanks for any help!
Problem solved: My version of NuGet was outdated as I was using Visual Studio 2012.
Updating to Visual Studio 2015 resolved this issue.

Categories