ASP.MVC 6 - Using dnu restore command

Recently I was playing around with the new MVC 6 web application templates to create some sample websites for learning the new features in the latest version. And suddenly out of the blue got the following error while try to start a debugging session and won't allow you the run the application without resolving this issue.

So I had no clue at first about, so I googled about the error and learned how this error came about and the ways to fix it too.

Visual Studio has got a project.json file as well as project.lock.json file inside the project. The project.json file can contain ranged versions or with specific versions like the one below

    "Microsoft.AspNet.Mvc": "6.0.0-beta6-*",
    "Newtonsoft.Json": "7.0.1"

The project.lock.json file will contain the specific version that is being used by the project. If we doesn't specified ranged versions in the project.json file, then both the files will be identical. The project.lock.json is used by dnx enviroment for loading the references for your project because using project.json file may cause to resolve the versions every time the application is run.

The lock file contians a key the very top called locked and when it's set to true then dnu or nuget will always restore and use the specific versions of every dependency specified in the lock file.

So whenever you enounter the NU1006 error, try to resolve it by using the Restore Package option and if the issue is not resolved then you have to manually do the restore using the command prompt.

The dnu commands in residing under the bin folder for the runtime and you can determine the runtime from project properties as shown below

The commands are located under 

<Windows drive>:\users\<username>\.dnx\runtimes\<your runtime>\bin

From there run the dnu restore command by specifying the path for project.json file in your project as shown below

 

Now you will be able to build your solution succesfully


No Comments

Add a Comment