dotnet恢复在本地引用的项目上引发错误 [英] dotnet restore throws error on locally referenced projects

查看:151
本文介绍了dotnet恢复在本地引用的项目上引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


这个问题是关于一个过时的功能。从2.x版本开始的dotnet核心项目不再需要project.json文件。

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

当我使用Visual Studio在本地构建项目时工作室一切正常。但是,当我使用Microsoft https://www.visualstudio.com/zh-cn/docs/build/apps/aspnet/aspnetcore-to-azure 我无法使其正常工作。

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.

我发现当我这样做时

dotnet restore

我收到此错误消息

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'.

我的解决方案中有5个项目,我认为dotnet还原正在尝试获取未建项目。

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

我的project.json包含以下内容:

My project.json contains this:

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


推荐答案

根据您的描述,似乎在推入时缺少4个依赖项VSTS的代码。我建议您检查VSTS中的所有文件。为了通过Visual Studio将ASP.Net核心应用程序发布和部署到Azure,我建议您阅读本文。阅读本文,以获取有关使用VSTS进行部署的更多信息。

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.

[根据我的评论进行更新]

根据我的经验,如果您开发.NET核心应用程序,则最好选择.NET核心类库。您可以将通用代码放在.NET Core项目的同一解决方案中,以供将来跨平台重用。

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.

这篇关于dotnet恢复在本地引用的项目上引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆