Visual Studio 2015 "nuget" issue? - c#

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

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.

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.

'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.

Installing Microsoft.AspNetCore.Mvc

I use Visual Studio Community 2015
Version 14.0.25123.00 Update 2
NuGet Package Manager 3.4.4
When trying to install Microsoft.AspNetCore.Mvc package in a .NET 4.6.1 console Application project, I get the following error:
install-package : Could not install package 'runtime.native.System 4.0.0-rc2-24027'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', 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.AspNetCore.Mvc -pre
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Can anyone help me out ?
Basically you can not install Microsoft.AspNetCore.Mvc in a console Application. In a console application from Microsoft.AspNetCore.* you can install only Microsoft.AspNetCore.Authentication.ActiveDirectory.
To prove this try this way:
Right click in the references
Chose Manage Nuget Packages...
From 3 tabs (Browse, Installed, Updates) choose Browse tab.
Write in the search box Microsoft.AspNetCore.
The reason you can not install that your application is simply a console app not MVC structure.

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