.netazurednxazure-pipelines

dotnet restore throws error on locally referenced projects


This question is about a depeciated feature. dotnet core projects from version 2.x and up no longer require a project.json file.

When I build my project locally using visual studio everything works fine. However when I build it in VSTS using the recommended process from microsoft https://www.visualstudio.com/en-us/docs/build/apps/aspnet/aspnetcore-to-azure I can't get it to work.

I'm finding that when I do

dotnet restore

I get this error message

Errors in C:\a\1\s\Wedding.WebApp\project.json
    Unable to resolve 'Wedding.Application' for '.NETFramework,Version=v4.6.1'.
    Unable to resolve 'Wedding.Common' for '.NETFramework,Version=v4.6.1'.
    Unable to resolve 'Wedding.Domain' for '.NETFramework,Version=v4.6.1'.
    Unable to resolve 'Wedding.Persistence' for '.NETFramework,Version=v4.6.1'.

I have 5 projects within my solution and I think the dotnet restore is trying to get unbuilt projects.

My project.json contains this:

"frameworks": {
  "net461": {
    "dependencies": {
      "Wedding.Application": {
        "target": "project"
      },
      "Wedding.Common": {
        "target": "project"
      },
      "Wedding.Domain": {
          "target": "project"
      },
      "Wedding.Persistence": {
          "target": "project"
      }
    }
  }
},

Solution

  • Based on your description, it seems there are 4 dependencies missing when push the code to VSTS. I would suggest you check all files in VSTS. For publish and deploy ASP.Net core application to Azure via Visual studio, I would suggest you read this article. Read this article for more information about use VSTS to deploy.

    [Update based on my comment]

    Based on my experience, if you develop a .NET core application, It is better to choose .NET core class library. you can put common code in .NET Core projects in the same solution for future cross-platform re-use.