There is no lock file in project "XXXXXX". To start a new lock file, run "dotnet recovery"

I have an ASP.NET Core Web API project and .Net Core Library project. The web API has a link to the library project as target : project . Project name of the Transformations library.
Below is the project project.json for both projects

project.json for web API

 "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", "type": "platform" }, "Microsoft.ApplicationInsights.AspNetCore": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Transformations": { "target": "project" }, "Microsoft.Extensions.DependencyInjection": "1.0.0", "Serilog.Extensions.Logging": "1.3.0-dev-10125", "Serilog.Sinks.RollingFile": "3.0.0", "Serilog.Settings.Configuration": "2.1.0", "Microsoft.AspNetCore.Diagnostics": "1.0.0" }, 

project.json for the library project

 { "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.6.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0" }, "frameworks": { "netstandard1.6": { "imports": "dnxcore50" } }, "configurations": { "Production": {}, "Staging": {} } } 

The build server below shows the project structure for Api and Transformation projects.

  D:\Jenkins\MyJenkinsProject\workspace\src\MySolution \Api \Transformation 

On the build server, I ran the following commands

  D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet restore 

and then

  D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet build 

I get an error

Project Transformations does not have a lock file. Run "dotnet restore" to create a new lock file.

Now, if I run the following commands in order, then everything will be fine.

  D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Transformation>dotnet restore D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet restore D:\Jenkins\MyJenkinsProject\workspace\src\MySolution\Api>dotnet build 

Questions
1> When a library is referred to as a project in an API project, why do I need to run dotnet restore separately for a library project? Why does this not work restores an unrealized project?

+5
source share
2 answers

From Zlatko Knezhevich :

This is design behavior. [...] If you want to restore all the dependencies for all your projects at once, so to speak, just run dotnet restore in the root of your solution (where you have the global.json file).

+2
source

I believe that you can just do dotnet build directly. it should automatically do dotnet restore .

-2
source

All Articles