Failed to resolve dependency in commerce engine project

When developing plugins for the Sitecore Commerce engine, after adding a reference to another project (e.g. engine plugins/features) you may encounter the following error (NU1001 The dependency could not be resolved):


Even if you follow your natural instincts, right click on references and click on restore packages, it still fails to resolve the dependency.

This is inconsistent behaviour in Visual Studio when working with .NET Core projects. A bullet proof way to fix this is to open a command prompt window at the root of the project, and run the following command:

dotnet restore

Voila! Magically, the reference is resolved.