Nuget misbehaving with newtonsoft.json package - c#

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.

Related

Nuget package installation fails although package should be supported

I am trying to install the package Microsoft.Extensions.DependencyInjection.Abstractions in my Visual Studio 2013 solution as part of a Sitecore installation. The solution has .NET target framework 4.5.2.
The installation fails with
Install-Package : Could not install package 'Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0'. You are trying to install this package into a project that targets
'.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the
package author.
At line:1 char:1
+ Install-Package Microsoft.Extensions.DependencyInjection.Abstractions -Version 1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
I have tried performing the installation in a completely new, empty solution but the installation still fails.
According to the link, there is a dependency to .NETStandard 1.0 but this should be supported by 4.5 according to this.
JaCraig's commment helped me solve this: I upgraded Nuget Package Manager from 2.8 to 2.12. Afterwards, there were no problems with the installation.

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.

The source at nuget.org is unreachable?

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

Categories