61

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

8
  • Could you check your csproj file? It shouldn't be readonly. Commented Nov 29, 2011 at 16:55
  • @DimaPasko: no not readonly I can manually add reference, nuget cant do. I create new project but I get same error. Commented Nov 29, 2011 at 17:16
  • What kind of project are you installing it into? Commented Nov 30, 2011 at 8:26
  • Have you tried another NuGet package? What is project type? Class Library? Commented Nov 30, 2011 at 9:28
  • I tried any project and any package. I receive same error. Commented Dec 3, 2011 at 0:24

20 Answers 20

82

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.
Sign up to request clarification or add additional context in comments.

5 Comments

Must be a bug in Nuget
Just deleting the EF folder in the packages folder will suffice.
@Ron, if 'enable package restore' is set up for that project.
Clearing the packages cache worked for me, under tools --> nuget manager -- Manage packager settings --> clear cache
I was struggling with it all day, tried everything. I thank you from the bottom of my heart
7

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.

Comments

7

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

2 Comments

In addition to this, I deleted Entity Framework from ./packages then ran the package manager command. Works.
I closed studio. Ran the command and restarted studio for success.
5

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.

Comments

5

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

Comments

3

by clearing package Cache the problem resolved:

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

1 Comment

I don't find the option "Clear Package Cache".
2

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

Comments

1

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.

Comments

1

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

Comments

1

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

Comments

1

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.

Comments

1

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.

Comments

0

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.

Comments

0

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

Comments

0

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

Comments

0

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.

Comments

0

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

Comments

0

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.

Comments

0

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.