NuGet Error NU1005

Scenario 1

Invalid restore input where RestorePackagesWithLockFile property is set to false but a packages lock file exists at C:\SourceCode\ContosoProject\Contoso.Library\packages.lock.json

Issue

There are 2 opt-in methods the lock file functionality, by setting the RestorePackagesWithLockFile property, or create a packages.lock.json next to the project file, and they are conflicting.

Solution

  • If you wish to continue using the lock file functionality, change RestorePackagesWithLockFile to true.
  • If you to wish to stop using the lock file functionality, remove the packages.lock.json file.

Scenario 2

RestoreForceEvaluate should not be used with RestoreLockedMode in the same command.

Issue

The commands are contrary to each other. RestoreForceEvaluate forces restore to reevaluate the dependencies generating a new lock file, while RestoreLockedMode prevents updating the lock file.

Solution

Consult the recommendations in the error message and do one of the following:

  • Rerun restore without locked mode to regenerate the lock file.
  • Rerun restore without force evaluate to avoid changing the lock file.