1

我正在尝试在 Ubuntu 16.04 上部署 .NET Core 应用程序。该项目包含对其他项目的引用(即不是通过 nuget),该应用程序在本地运行良好(win10-x64)但是在服务器上键入时dotnet restore我收到以下日志:

XXXXXX@ip-XXX-XXX-XXX-X:/home/XXXXXX$ dotnet restore
    log  : Restoring packages for /home/XXXXXX/project.json...
    error: Unable to resolve 'XXXXXX.Configuration (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
    error: Unable to resolve 'XXXXXX.DataModels (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
    error: Unable to resolve 'XXXXXX.DAL (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
    error: Unable to resolve 'XXXXXX.Application (>= 1.0.0-0)' for '.NETCoreApp,Version=v1.0'.
    error: Unable to resolve 'XXXXXX.BLL (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
    log  : Lock file has not changed. Skipping lock file write. Path: /home/XXXXXX/project.lock.json
    log  : /home/XXXXXX/project.json
    log  : Restore failed in 4546ms.

log  : Lock file has not changed. Skipping lock file write. Path: 

我已经在此处此处此处查看了相关问题中的建议,但是似乎没有一个解决方案可以解决我的问题。

鉴于核心框架的变化速度,我将指定正在使用的版本和项目的 project.json 文件:

XXXXXX.Configuration(.NET Core 类库)project.json:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.1"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

XXXXXX.DataModels (.NET Core 类库) project.json

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.1",
    "XXXXXX.Application": "1.0.0-0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

XXXXXX.DAL(.NET Core 类库)project.json

{
  "version": "1.0.0-*",

  "dependencies": {
    "MySql.Data": "7.0.6-IR31",
    "NETStandard.Library": "1.6.1",
    "XXXXXX.Application": "1.0.0-0",
    "XXXXXX.Configuration": "1.0.0-*",
    "XXXXXX.DataModels": "1.0.0-*"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

XXXXXX.Application(.NET Core 类库) poject.json

{
  "version": "1.0.0-0",

  "dependencies": {
    "Microsoft.AspNetCore.Mvc.Abstractions": "1.1.0",
    "Microsoft.AspNetCore.Mvc.Core": "1.1.0",
    "Microsoft.AspNetCore.Mvc.DataAnnotations": "1.1.0",
    "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.1.0",
    "MySql.Data": "7.0.6-IR31",
    "NETStandard.Library": "1.6.1",
    "System.Data.SqlClient": "4.3.0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

XXXXXX.BLL(.NET Core 类库)project.json

{
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.Extensions.Configuration.Binder": "1.1.0",
    "NETStandard.Library": "1.6.1",
    "XXXXXX.Application": "1.0.0-*",
    "XXXXXX.Configuration": "1.0.0-*",
    "XXXXXX.DAL": "1.0.0-*",
    "XXXXXX.DataModels": "1.0.0-*"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

最后,.NET Core Web UI proejct 将它们联系在一起:

XXXXXX.WebUI 项目.json

{
  "dependencies": {
    "BundlerMinifier.Core": "2.3.327",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Mvc": "1.1.1",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Session": "1.1.0",
    "PaulMiami.AspNetCore.Mvc.Recaptcha": "1.1.1",
    "Microsoft.AspNetCore.Mvc.Abstractions": "1.1.1",
    "Microsoft.Extensions.Options": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "XXXXXX.DataModels":  {
        "version":"1.0.0-*",
        "target": "project"
    },
    "XXXXXX.Application": {
        "version": "1.0.0-0",
        "target": "project"
    },
    "XXXXXX.Configuration": {
      "version": "1.0.0-*",
      "target": "project"
    },
    "XXXXXX.DAL": {
        "version": "1.0.0-*",
        "target": "project"
    },
    "XXXXXX.BLL": {
         "version": "1.0.0-*",
         "target": "project"
    }
  },

  "tools": {
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "copyToOutput": [ "web.development.environment.json" ]
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "runtimes": {
    "win10-x64": {},
    "ubuntu.16.04-x64":  {}
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config",
      "global.json",
      "project.json",
      "web.development.environment.json"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

我还有一个 global.json,它在发布时驻留在根文件夹中(项目之上一层)

{
  "projects": [ 
    "src", 
    "/home/XXXXXX/XXXXXX.Application.dll", 
    "/home/XXXXXX/XXXXXX.Configuration.dll", 
    "/home/XXXXXX/XXXXXX.DataModels.dll", 
    "/home/XXXXXX/XXXXXX.Common.dll",
    "/home/XXXXXX/XXXXXX.BLL.dll", 
    "/home/XXXXXX/XXXXXX.DAL.dll", 
    "/home/XXXXXX/XXXXXX.Notifications.Client.dll", 
    "/home/XXXXXX/XXXXXX.Notifications.DataModels.dll",
    "/home/XXXXXX/XXXXXX.WebUI.dll"
  ]
}

编辑

VS 中的发布/构建创建了以下层次结构:

   /home
      /XXXXXX
          /bin
          /refs
          /runtimes
          /Views
          /wwwroot
      global.json
      project.json
      XXXXXX.Configuration.dll
      XXXXXX.Application.dll
      XXXXXX.DataModels.dll
      XXXXXX.BLL.dll
      XXXXXX.DAL.dll
      XXXXXX.WebUI.dll
      web.config
      web.development.environment.json
      (+ Many .NET dlls)

因此,所有项目都是在同一级别构建和放置的 - 似乎是错误的,但它是自动化的。

帮助!

4

1 回答 1

0

从本质上讲,问题出现在一些第三方软件包仅支持 netcoreapp1.1 的情况下。

我在 VS 2017 中重新创建了我的项目(使用 ye olde .csproj)升级到 1.1。现在一切正常。

我的建议是获取 VS 2017 并移植任何依赖于旧版本 dotnet 核心的项目,以避免以后出现 Nuget 问题。

希望在未来几个月内平台更加稳定。

于 2017-03-17T01:21:18.040 回答