Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing package causes NuGet package restore to fail

We are enthusiastic users of NuGet, both for internally built as well as 3rd party packages.

We've recently started to enable the NuGet Package Restore option in some of our build projects to reduce the amount of binary files we commit to source control, but we're coming up against a problem.

We're seeing Visual Studio taking a really long time to start up and, once it has started (which could take over half an hour), the subsequent build is then equally time-consuming. While this is happening, you can see many child NuGet processes appearing and dying in process explorer.

We have found that if the version of the package that is referenced in the packages.config file is not available from any of the configured package sources (perhaps it's an old version of an internal package and someone helpful has been cleaning up our local repo), it seems as though NuGet and Visual Studio get into some sort of infinite (or at the very least long-running) retry loop.

If we run the NuGet install command from the command line we get back the error

>.nuget\NuGet.exe install project\packages.config -o packages
Unable to find version '1.0.0.1' of package 'my.internal.package'.

but it looks as though this isn't being consumed correctly by Visual Studio/NuGet.

  • Does NuGet log its actions anywhere?
  • Can we limit the NuGet restore retries or time outs (perhaps in the nuget.targets file?)
  • It looks as though NuGet's semantic versioning isn't being used, because in our above scenario 1.0.0.2 is available from the repo, can this be enabled?
like image 718
Unsliced Avatar asked Nov 03 '22 05:11

Unsliced


1 Answers

This seems to similar to this issue http://nuget.codeplex.com/workitem/2970 temporary workaround worked for me is to open nuget.targets and replace
<!-- We need to ensure packages are restored prior to assembly resolve -->
<ResolveReferencesDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(ResolveReferencesDependsOn);
</ResolveReferencesDependsOn>
with

<BuildDependsOn Condition="$( RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

Close and reload solution in VS. this would make the build depend on restore packages instead of assembly resolve which seems to solve the issue.

hope this helps.

like image 100
Deepak Avatar answered Nov 17 '22 12:11

Deepak