NuGet add reference error while installing packages

.NetVisual Studio-2010Nuget

.Net Problem Overview


I am not able to install any package by Nuget. For example when I want install entity framework I receive following error:

install-package EntityFramework
Successfully installed 'EntityFramework 4.2.0.0'.
Successfully uninstalled 'EntityFramework 4.2.0.0'.
Install failed. Rolling back...
Install-Package : Failed to add reference to 'EntityFramework'.
At line:1 char:16
+ install-package <<<<  EntityFramework
   + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
   +FullyQualifiedErrorId:NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

I receive same error while installing every package from console or gui. Reinstalling nuget, disabling other extentions and running VS as admin did not help me.

Regards

.Net Solutions


Solution 1 - .Net

I had this problem too, the fix that worked for me was:

  1. Delete all the folders inside of the packages folder.
  2. Update all packages in Nuget Package Manager.

Solution 2 - .Net

Suffer the same. In the end it occurs that in

Tools -> Options -> Nuget Package Manager -> Package Sources 

nuget.org was unchecked. Checking it solve the problem.

Solution 3 - .Net

Here is what solved it for me: VS2012 with EF6

I found my answer here: http://richardschneider.net/blog/wordpress/?p=21

From the VS command prompt, run the following command:

regsvr32 "C:\Program Files (x86)\Common Files\microsoft shared\MSEnv\VsLangproj.olb"

After that, go to Package manager console and run the following:

Install-Package EntityFramework -Version 6.1.3

Solution 4 - .Net

I ran into this issue as well. Unfortunately, the only solution that worked for me was completely uninstalling Visual Studio, deleting any folders left over after the uninstall, rebooting computer, and then re-installing Visual Studio.

Visual Studio 'repair' did not work for me. Only complete re-install.

Solution 5 - .Net

I had this problem too what i did was type in the package manager console Uninstall-Package EntityFramework -force, then delete the EntityFramework Folder in Package Folder, and then install it again Install-Package EntityFramework

Solution 6 - .Net

by clearing package Cache the problem resolved:

Tools->package Manager->Package Manager Settings-> Clear Package Cache

Solution 7 - .Net

After updating my Visual Studio 2015 nuget stopped working.

After reading the posted solutions I founded that's a know bug, see http://blog.nuget.org/20150226/nuget-3.0-beta2.html

From Visual Studio I unistalled nuget extension, closed visual studio , downloaded and installed latest nuget version from https://dist.nuget.org/index.html

It worked

Solution 8 - .Net

I ran into the same problem. I did the following:

update-package jQuery.

Install-Package Twitter.Bootstrap -Version 3.0.0

It worked , probably because the Bootstrap -version 3.0.0 work with the JQuery most recent version.

Solution 9 - .Net

For me, the problem was fixed with git clean -dfx.

Solution 10 - .Net

Running this command from an elevated prompt resolved my issue:

> regsvr32 "C:\Program Files (x86)\Common Files\microsoft > shared\MSEnv\VsLangproj.olb"

Source: https://docs.nuget.org/Release-Notes/Known-Issues

Solution 11 - .Net

Had nearly the same problem on my Windows 10 machine and could't figure out why no references worked in Visual Studio 2015 after running "Get Latest Version" in TFS and why I could not restore NuGet packages. For some reason NuGet added two packages folders to the computer and I had only deleted the package folder in the project:

Locations:

> C:\Users\YourUser\Documents\Visual Studio > 2015\Projects\YourProject\packages C:\Users\YourUser.nuget\packages

When both of the packages folders were removed I could restore NuGet packages and everything worked again.

Solution 12 - .Net

When I went to Visual Studio 2015 Update 3, it broke for me, I tried many of the steps, in other answers to clear package folders / caches / etc.

In the end I got it working via:

  • Full uninstall.
  • Went looking for all files/locations of visual studio (AppData/Documents/etc).
  • New re-install, it still didn't work (I had missed files in other locations).
  • Ran devenv commands : like /resetuserdata and /resetsettings
  • Ran a repair action.

So just note doing a full uninstall won't clear out all your settings/cache data.

Solution 13 - .Net

The problem occurred in my entity framework version. I was using an older version of entity framework, After deleting older version of EF and re installing it with the latest version available helped me solving this issue.

Solution 14 - .Net

I deleted the project, created fresh one, first added entity framework reference. it worked.. moved necessary code back into the project

Solution 15 - .Net

In my case, deleting all occurrences of 'EntityFramework...' files in the Bin folder (open the folder in Windows Explorer) worked form me. I didn't have the packages folder in my project. The 'EntityFramework...' files were added by different action.

NOTE: You may need to rebuild project to remove error(s).

Solution 16 - .Net

I also ran into this case when installing the AttributeRouting package. After googling a while, i tried the following steps and it works for me:

  1. Tools > Extensions and Updates: uninstall NuGet Package Manager and reinstall it. Restart the Visual Studio.

  2. Tools > Options > Package Manager > Package Sources: make sure to check for the nuget.org source.

Hope this help.

Solution 17 - .Net

In my case, specifying the desidered version has solved the problem. That's probably because different projects in the same solution reference different version of the same Package. In that case, Nuget doesn't know the desidered version, hence the exception.

Just use this syntax:

Install-Package XXXX -Version A.B.C.D

Solution 18 - .Net

I had this problem in Visual Studio 2017 in Windows 10.

I had an existing project, and I updated the .Net Framework from 4.6.2 to 4.7.2, and the Entity Framework from 6.1.3 to 6.2.0. I rebuilt and deployed the application, but it failed to connect to my database because the reference to EntityFramework.SqlServer was broken.

I used the Package Manager UI to remove the Entity Framework from both projects in my solution. I attempted to re-add the Entity Framework, but it failed every time. I had to remove the Entity Framework from both projects and save the solution to source control (TFS), and then add the Entity Framework back in.

This successfully added the Entity Framework and the EntityFramework.SqlServer reference.

Solution 19 - .Net

Add new Source with following path and Tick it. https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/

Solution 20 - .Net

Tools -> NuGet Package Manager -> Package Manager Settings -> go to Package Sources and remove the source that is generating the problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSam FarajpourGhamariView Question on Stackoverflow
Solution 1 - .Netmarvc1View Answer on Stackoverflow
Solution 2 - .NetArtur MichajlukView Answer on Stackoverflow
Solution 3 - .NetDragos DurlutView Answer on Stackoverflow
Solution 4 - .NetClearCloud8View Answer on Stackoverflow
Solution 5 - .NetLuis TellezView Answer on Stackoverflow
Solution 6 - .NetideazView Answer on Stackoverflow
Solution 7 - .NetEnzo ApollonioView Answer on Stackoverflow
Solution 8 - .NetGul SaeedView Answer on Stackoverflow
Solution 9 - .NetKijana WoodardView Answer on Stackoverflow
Solution 10 - .NetvanandshView Answer on Stackoverflow
Solution 11 - .NetOgglasView Answer on Stackoverflow
Solution 12 - .NetNick JosevskiView Answer on Stackoverflow
Solution 13 - .NetManozView Answer on Stackoverflow
Solution 14 - .NetPooranView Answer on Stackoverflow
Solution 15 - .NetSimpaView Answer on Stackoverflow
Solution 16 - .NetDoan VuView Answer on Stackoverflow
Solution 17 - .NetMarconlineView Answer on Stackoverflow
Solution 18 - .NetChris PayneView Answer on Stackoverflow
Solution 19 - .NetPrashantView Answer on Stackoverflow
Solution 20 - .NetAbdelrahman ELGAMALView Answer on Stackoverflow