Install-Package: Failed to add reference

Feb 17, 2012 at 2:44 PM
Edited Feb 17, 2012 at 6:32 PM

I updated nuget yesterday and no I can't install any packages that need to add a reference. This happens for most all of the packages im trying to install (Automapper, Autofac.mvc3, etc). Although I was able to install twitter.bootstrap, jquery, etc.

I have uninstalled, reinstalled, reboot. No sure what else todo.

Any Ideas?

PM> Install-Package Newtonsoft.Json 
Successfully installed 'Newtonsoft.Json 4.0.8'.
Successfully uninstalled 'Newtonsoft.Json 4.0.8'.
Install failed. Rolling back...
Install-Package : Failed to add reference to 'Newtonsoft.Json'.
At line:1 char:16
+ Install-Package <<<<  Newtonsoft.Json 
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
PM> install-package twitter.bootstrap
'Twitter.Bootstrap 2.0.0' already installed.
Successfully added 'Twitter.Bootstrap 2.0.0' to ARI.Core.
PM> Install-Package jQuery 
Successfully installed 'jQuery 1.7.1'.
Successfully added 'jQuery 1.7.1' to ARI.Core.
 
Here is the vs output from an attempt to install automapper:
------- Installing...AutoMapper 2.0.0 -------
Added file 'AutoMapper.dll' to folder 'AutoMapper.2.0.0\lib\net40-client'.
Added file 'AutoMapper.xml' to folder 'AutoMapper.2.0.0\lib\net40-client'.
Added file 'AutoMapper.dll' to folder 'AutoMapper.2.0.0\lib\sl4'.
Added file 'AutoMapper.XML' to folder 'AutoMapper.2.0.0\lib\sl4'.
Added file 'AutoMapper.2.0.0.nupkg' to folder 'AutoMapper.2.0.0'.
Successfully installed 'AutoMapper 2.0.0'.
Added file 'packages.config'.
Removed reference 'AutoMapper.dll' from project 'ARI.Web'
Added file 'packages.config'.
Removed file 'AutoMapper.dll' to folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib\net40-client'.
Removed file 'AutoMapper.xml' to folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib\net40-client'.
Removed folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib\net40-client'.
Removed file 'AutoMapper.dll' to folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib\sl4'.
Removed file 'AutoMapper.XML' to folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib\sl4'.
Removed folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib\sl4'.
Removed folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0\lib'.
Removed file 'AutoMapper.2.0.0.nupkg' to folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0'.
Removed folder 'C:\Users\ari108\Documents\Visual Studio 2010\Projects\ari.mvc.intranet.template\packages\AutoMapper.2.0.0'.
Successfully uninstalled 'AutoMapper 2.0.0'.
Install failed. Rolling back...
Operation failed.
==============================
Feb 21, 2012 at 7:51 AM

Can you run VS with the /log switch and share the log file?

Feb 22, 2012 at 1:46 PM
Edited Feb 22, 2012 at 8:32 PM

dotnetjunky,

Hope this is what your looking for:

Click Me

Feb 28, 2012 at 7:50 PM

Not sure if this helps or not but I read a post and set the following:

Set-PsDebug -trace 2

With the output being:

Install-Package Autofac.Mvc3 
   1+  <<<< Install-Package Autofac.Mvc3 
Attempting to resolve dependency 'Autofac (≥ 2.5.2.830)'.
Successfully installed 'Autofac 2.5.2.830'.
Successfully installed 'Autofac.Mvc3 2.5.2.830'.
Successfully uninstalled 'Autofac 2.5.2.830'.
Install failed. Rolling back...
   2+                                     if <<<<  ($_.FullyQualifiedErrorId -ne "NativeCommandErrorMessage" -and $ErrorView -ne "CategoryView") {
   3+                                        $myinv = <<<<  $_.InvocationInfo
    ! SET $myinv = 'System.Management.Automation.InvocationInfo'.
   4+                                        switch <<<<  -regex ( & { Set-StrictMode -Version 1; $myinv.MyCommand.CommandType } )
    ! CALL scriptblock.
   4+                                        switch -regex ( & {  <<<< Set-StrictMode -Version 1; $myinv.MyCommand.CommandType } )
   4+                                        switch -regex ( & { Set-StrictMode -Version 1; $myinv.MyCommand. <<<< CommandType } )
  24+                                                if <<<<  ( & { Set-StrictMode -Version 1; $myinv.MyCommand.Name } )
    ! CALL scriptblock.
  24+                                                if ( & {  <<<< Set-StrictMode -Version 1; $myinv.MyCommand.Name } )
  24+                                                if ( & { Set-StrictMode -Version 1; $myinv.MyCommand. <<<< Name } )
  26+                                                    $myinv.MyCommand.Name + <<<<  " : "; break;
  26+                                                    $myinv.MyCommand.Name + " : "; break <<<< ;
   2+                                    if <<<<  ($_.FullyQualifiedErrorId -eq "NativeCommandErrorMessage") {
   7+                                         if <<<<  ($_.InvocationInfo) {
   8+                                             $posmsg = <<<<  $_.InvocationInfo.PositionMessage
    ! SET $posmsg = '
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc...'.
  13+                                         if <<<<  ( & { Set-StrictMode -Version 1; $_.PSMessageDetails } ) {
    ! CALL scriptblock.
  13+                                         if ( & {  <<<< Set-StrictMode -Version 1; $_.PSMessageDetails } ) {
  13+                                         if ( & { Set-StrictMode -Version 1; $_. <<<< PSMessageDetails } ) {
   1+  <<<< & { Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
    ! CALL scriptblock.
   1+ & {  <<<< Set-StrictMode -Version 1; $this.Exception.InnerException.PSMessageDetails }
   1+ & { Set-StrictMode -Version 1; $this.Exception.InnerException. <<<< PSMessageDetails }
  17+                                         $indent = <<<<  4
    ! SET $indent = '4'.
  18+                                         $width = <<<<  $host.UI.RawUI.BufferSize.Width - $indent - 2
    ! SET $width = '214'.
  20+                                         $indentString = <<<<  "+ CategoryInfo          : " + $_.CategoryInfo
    ! SET $indentString = '+ CategoryInfo          : NotSpecified: (:) [Ins...'.
  21+                                         $posmsg += <<<<  "`n"
    ! SET $posmsg = '
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc...'.
  22+                                         foreach <<<< ($line in @($indentString -split "(.{$width})")) { if($line) { $posmsg += (" " * $indent + $line) } }
  22+                                         foreach($line in @($indentString -split <<<<  "(.{$width})")) { if($line) { $posmsg += (" " * $indent + $line) } }
  22+                                         foreach($line in @($indentString -split "(.{$width})")) { if <<<< ($line) { $posmsg += (" " * $indent + $line) } }
  22+                                         foreach($line in @($indentString -split "(.{$width})")) { if($line) { $posmsg += <<<<  (" " * $indent + $line) } }
    ! SET $posmsg = '
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc...'.
  24+                                         $indentString = <<<<  "+ FullyQualifiedErrorId : " + $_.FullyQualifiedErrorId
    ! SET $indentString = '+ FullyQualifiedErrorId : NuGetCmdletUnhandledEx...'.
  25+                                         $posmsg += <<<<  "`n"
    ! SET $posmsg = '
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc...'.
  26+                                         foreach <<<< ($line in @($indentString -split "(.{$width})")) { if($line) { $posmsg += (" " * $indent + $line) } }
  26+                                         foreach($line in @($indentString -split <<<<  "(.{$width})")) { if($line) { $posmsg += (" " * $indent + $line) } }
  26+                                         foreach($line in @($indentString -split "(.{$width})")) { if <<<< ($line) { $posmsg += (" " * $indent + $line) } }
  26+                                         foreach($line in @($indentString -split "(.{$width})")) { if($line) { $posmsg += <<<<  (" " * $indent + $line) } }
    ! SET $posmsg = '
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc...'.
  28+                                         if <<<<  ($ErrorView -eq "CategoryView") {
  32+                                             $_.Exception.Message + <<<<  $posmsg + "`n "
Install-Package : Failed to add reference to 'Autofac.Configuration'.
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc3 
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Mar 5, 2012 at 2:49 PM

I finally ended up uninstalling and reinstalling VS2010 and this seems to have resolved the issue. This was the last thing I wanted to do but nothing else seemed to work. Needless to say my nuget is back!.