question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UX improvement: dotnet CLI should automatically restore when necessary

See original GitHub issue

Error messages which instruct the user to carry out some action can generally be replaced with the action itself. In this case, the error NU1009: The expected lock file doesn't exist. Please run "dotnet restore" to generate a new lock file and other similar warnings/errors are annoying and it seems they should be replaced with an automatic run of dotnet restore.

Steps to reproduce

dotnet new
dotnet run

Expected behavior

The dotnet cli recognizes that project.lock.json is missing or out of date and automatically runs dotnet restore without prompting the user to do it.

log  : The expected lock file doesn't exist. Automatically restoring packages to recreate it.
log  : Restoring packages for /home/bburns/projects/dotnettest/project.json...
log  : Writing lock file to disk. Path: /home/bburns/projects/dotnettest/project.lock.json
log  : /home/bburns/projects/dotnettest/project.json
log  : Restore completed in 709ms.
Project dotnettest (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling dotnettest for .NETCoreApp,Version=v1.0

Compilation succeeded.
    0 Warning(s)
    0 Error(s)

Time elapsed 00:00:00.8663525

Hello World!

Actual behavior


bburns@workstation:~/projects/dotnettest$ dotnet run
The current project is not valid because of the following errors:
/home/bburns/projects/dotnettest/project.lock.json(1,0): error NU1009: The expected lock file doesn't exist. Please run "dotnet restore" to generate a new lock file.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information: Version: 1.0.0-preview2-003121 Commit SHA-1 hash: 1e9d529bc5

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
livarcocccommented, Dec 20, 2016

@benjamincburns I think you are right. I am re-opening this to see if there is anything at all that we can do that won’t risk causing more trouble than fixing it.

0reactions
livarcocccommented, May 8, 2017

We are tracking this work at https://github.com/dotnet/cli/issues/6105. Closing this one as a dup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet restore command - .NET CLI
Learn how to restore dependencies and project-specific tools with the dotnet restore command.
Read more >
NuGet packages need to be restored before building. ...
The solution to right-click Dependencies and choose Restore worked like a charm. The only reference the "broken" project had was Microsoft.
Read more >
Compile your changes on the fly with .NET Core Watch
Make sure your dev machine has dotnet-watch by restoring packages. dotnet restore. Test it out. Now all you need to do is run...
Read more >
Dotnet restore vs nuget restore. Share. In my code repo, there
NET Core 3. This step should execute the following command for every packages. config while blue one is PackageReference format) Running restore at...
Read more >
dotnet restore is now an implicit command · Issue #23
The .NET Core development experience no longer requires explicit use of the dotnet restore command. This improvement is delivered with the .NET ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found