dotnet restore throws error on locally referenced projects

空扰寡人 提交于 2019-12-02 06:06:06

问题


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"
      }
    }
  }
},

回答1:


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.



来源:https://stackoverflow.com/questions/39551233/dotnet-restore-throws-error-on-locally-referenced-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!