6

Environment: VS Enterprise 2015 Update 1, Package Manager Console Host Version 3.3.0.167

Steps to reproduce: just create a new project (e.g. console application) targetting .Net 4.5.2 (but tried with other .net versions as well).

When I install a nuget package, the package is downloaded and seemingly installed without error. However, nuget does not add a reference to the dll. When looking in the packages folder, it turns out that there are no .dlls unpacked, although the .nupkg file is there and is not corrupt (I can open it with nuget package explorer and see the content of the lib folder).

Any idea what could be causing this?

Output in package manager console:

PM> install-package log4net -verbose
  Attempting to gather dependencies information for package 'log4net.2.0.5' with respect to project 'ConsoleApplication4', targeting '.NETFramework,Version=v4.5.2'
  Attempting to resolve dependencies for package 'log4net.2.0.5' with DependencyBehavior 'Lowest'
  Resolving actions to install package 'log4net.2.0.5'
  Resolved actions to install package 'log4net.2.0.5'
  For adding package 'log4net.2.0.5' to project 'ConsoleApplication4' that targets 'net452'.
  For adding package 'log4net.2.0.5' to project 'ConsoleApplication4' that targets 'net452'.
  Adding package 'log4net.2.0.5' to folder 'c:\Projects\ConsoleApplication4\packages'
  Added package 'log4net.2.0.5' to folder 'c:\Projects\ConsoleApplication4\packages'
  Added package 'log4net.2.0.5' to 'packages.config'
  Added file 'packages.config' to project 'ConsoleApplication4'.
  Successfully installed 'log4net 2.0.5' to ConsoleApplication4

content of the package folder:

C:\Projects\ConsoleApplication4\packages\log4net.2.0.5>tree /f .
Folder PATH listing for volume OSDisk
Volume serial number is 8CE4-F2E5
C:\PROJECTS\CONSOLEAPPLICATION4\PACKAGES\LOG4NET.2.0.5
¦   log4net.2.0.5.nupkg
¦
+---lib
    +---net10-full
    ¦       log4net.xml
    ¦
    +---net11-full
    ¦       log4net.xml
    ¦
    +---net20-full
    ¦       log4net.xml
    ¦
    +---net35-client
    ¦       log4net.xml
    ¦
    +---net35-full
    ¦       log4net.xml
    ¦
    +---net40-client
    ¦       log4net.xml
    ¦
    +---net40-full
    ¦       log4net.xml
    ¦
    +---net45-full
            log4net.xml

UPDATE: Happens to some, but not all nuget packages

jeroenh
  • 26,362
  • 10
  • 73
  • 104
  • 1
    I'm having the exact same issue on my home PC (but not on my work PC) and have not been able to solve it yet. I've tried reinstalling VS and I've tried a previous version of Nuget Package Manager. – Anthony Jan 05 '16 at 03:29
  • 1
    Log4Net seems to work for me but other packages like RestSharp and Twilio don't extract the DLL files or add the reference to the project – Anthony Jan 05 '16 at 03:36

3 Answers3

13

The workaround outlined on this page seemed to work - https://connect.microsoft.com/VisualStudio/feedback/details/1656768/installing-certain-nuget-packages-fails-to-actually-extract-the-dll-files-to-the-relevant-lib-folder-and-fails-to-add-an-assembly-reference-to-the-csproj-file

Posted by Miles Rush on 11/25/2015 at 12:16 PM

Just fixed this on my > system. Went in to the user profile NuGet cache (C:\Users\.nuget\packages), and deleted everything in there. I think during the restore process my cache was cleared of all DLL files, and when I tried to install a package it was using the cache instead of the files off of NuGet. Now that I've cleared the cache, I can now install the NuGet packages.

Anthony
  • 1,706
  • 2
  • 22
  • 46
  • This fixed the problem I'd been banging my head against for hours. I had tried repairing my VS installation, clearing the AppData\Local\NuGet cache, deleting my entire TFS folder and pulling it again from the server, system restore, making sacrifices to the ancient gods...this is the first thing that worked. I owe you for reals. – Isaac Lyman Jun 21 '16 at 20:00
1

I just encountered this issue (VS2017 Enterprise) and while the above answer did not solve the problem, deleting everything in the packages folder for the solution did.

1

Had a similar behavior on our build agent. Reason: the .nupkg file was added to the repository! In that case, nuget assumes that the package already exists and will not unpack the .nupkg file.

Removed the file from the repository, and the build passed.

Thorsten Hüglin
  • 1,217
  • 10
  • 11