2

I have added a NuGet package to my solution and enabled package restore on the solution. This correctly created the .nuget folder with targets file etc.

The NuGet package is actually another project which becomes a dependency in the solution. Initially I added this package to the solution manually.

To Test this NuGet feature, I deleted the folder underneath the packages folder.

At that point I then get compiler errors obviously because other dependent projects are reliant on the project that has just been removed.

When I build the solution, I'm expecting NuGet to go and download the NuGet packages that it requires is this is set to Enable Package Restore, and then build successfully as all other dependent projects can now build.

However, I see no evidence of the NuGet package from being downloaded in the output, and the build errors remain the same as if the project hasn't been downloaded.

Can anyone confirm whether there is something I am missing or am doing wrong here?

jaffa
  • 26,770
  • 50
  • 178
  • 289

2 Answers2

1

To my knowledge deleting packages under the packages folder should be restored by NuGet's package restore feature.

It would be helpful to:

  1. See the actual build error.
  2. Know which packages you are trying to restore.

Some packages, such as ours, rely on .targets files which have issues when being used in package restore.

Immo Landwerth
  • 3,239
  • 21
  • 22
1

Make sure that NuGet.Config in your solution folder has "packageRestore" option enabled:

<?xml version="1.0" encoding="utf-8"?>  
<configuration>  
    <packageRestore>  
        <add key="enabled" value="True" />  
    </packageRestore>  
</configuration>  

Also it should be enabled globally in "C:\Users\%UserName%\Application Data\NuGet\NuGet.Config" (it can be set from within VS, Tools->Options->Package Manager.

Also note that there's another approach for restoring package since NuGet 2.7 - "Automatic Package Restore". See doc for more info: http://docs.nuget.org/docs/reference/package-restore and http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore

Shrike
  • 9,218
  • 7
  • 68
  • 105