尝试 dotnet restore 多项目时无法解决错误的解决方法 [英] Unable to resolve error when try dotnet restore multi project solution

查看:30
本文介绍了尝试 dotnet restore 多项目时无法解决错误的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在本地构建的解决方案,我创建了一个新构建并添加了一个步骤

I've got a solution that builds locally and I've created a new build and added one step to it

dotnet restore

我收到此错误消息:

    ... OTHER SUCCESSFUL INSTALLATIONS ...
    log  : Installing Microsoft.Extensions.FileProviders.Abstractions 1.0.0.
    log  : Installing Microsoft.Extensions.Configuration.Abstractions 1.0.0.
    log  : Installing Microsoft.Extensions.DependencyInjection.Abstractions 1.0.0.
    log  : Writing lock file to disk. Path: C:a1sWedding.WebAppproject.lock.json
    log  : C:a1sWedding.WebAppproject.json
    log  : Restore failed in 13722ms.
    Errors in C:a1sWedding.WebAppproject.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.WebApp.Setup' for '.NETFramework,Version=v4.6.1'.

它指的是我的主要网络项目引用的其他三个项目.

Its refering to the three other projects that my main web project references.

这是我的 project.json

This is my project.json

    {
      "dependencies": {
        "Microsoft.AspNetCore.Diagnostics": "1.0.0",
        "Microsoft.AspNetCore.Mvc": "1.0.1",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
        "Microsoft.AspNetCore.StaticFiles": "1.0.0",
        "Microsoft.Extensions.Configuration.Json": "1.0.0",
        "Microsoft.Extensions.Logging.Console": "1.0.0",
        "Microsoft.Extensions.Logging.Debug": "1.0.0"
      },

      "tools": {
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
      },

      "frameworks": {
        "net461": {
          "dependencies": {
            "Wedding.Application": {
              "target": "project"
            },
            "Wedding.Common": {
              "target": "project"
            },
            "Wedding.WebApp.Setup": {
              "target": "project"
            }
          }
        }
      },

      "buildOptions": {
        "emitEntryPoint": true,
        "preserveCompilationContext": true
      },

      "publishOptions": {
        "include": [
          "wwwroot",
          "web.config"
        ]
      },

      "scripts": {
        "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
      }
    }

有谁知道为什么这可能会出错?

Does anyone know why this might be erroring?

推荐答案

你的 dependenciesframeworks 块在我看来不正确:我希望你的库依赖于在 dependencies 块中声明,而不是在 frameworks 块中声明.对于一个项目引用另一个项目,它通常更像这样:

Your dependencies and frameworks block don't look correct to me: I would expect the libraries you depend on to be declared within the dependencies block, not the frameworks block. It would more typically resemble this, for one project referencing another:

{

  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Wedding.Application": { "target": "project" },
    "Wedding.Common": { "target": "project" },
    "Wedding.WebApp.Setup": { "target": "project" }
  },

  "frameworks": {
    "net461": {
      "imports": []
    }
  },

  ...
}

这篇关于尝试 dotnet restore 多项目时无法解决错误的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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