将项目从ASP.NET 5 RC1迁移到ASP.NET Core 1.0的依赖性问题

时间:2016-05-25 16:49:35

标签: c# asp.net-core dnx .net-core .net-core-rc2

我很难将我的asp.net(核心)应用从 dnx46 转换为 .netcoreapp1.0 ,因为有两个特殊的依赖关系( Microsoft。 Azure.ServiceBus System.IO.Ports.SerialPort

积极的,我打赌有一天这些功能最终将落在.net核心上......但与此同时,我发现将我的应用从绰号 dnx46 转换为 .netstandard1.3 允许我解析ServiceBus依赖项。

解析 System.IO.Ports.SerialPort 然而仍然是一个问题,我不明白如何使这项工作。我希望在.netstandard1.3名字对象中导入 net462 框架,将允许查找System.IO.Ports.SerialPort对象,但它不会。

我错过了什么?

作为参考,有我的project.json:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.NETCore.Platforms": "1.0.1-*",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-rc2-final",
    [...more stuff...]
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        // To be restored when they'll become available on .net core
        //  "Microsoft.WindowsAzure.ConfigurationManager": "3.2.1",
        //  "WindowsAzure.ServiceBus": "3.2.1",
      }
    },
    "netstandard1.3": {
      "buildOptions": {
        "define": [ "INCLUDE_WINDOWSAZURE_FEATURE" ]
      },
      // Imports of net462 fixes loading of
      //  - NewtonSoft.Json
      //  - System.Runtime.Loader for "Microsoft.NETCore.App"
      "imports": [
        "net462"
      ],
      "dependencies": {
        "Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027"
        "Microsoft.WindowsAzure.ConfigurationManager": "3.2.1",
        "WindowsAzure.ServiceBus": "3.2.1",
      }
    }
  }
}

2 个答案:

答案 0 :(得分:2)

  

解决System.IO.Ports.SerialPort然而仍然是一个问题,我不明白如何使这项工作。我希望在.netstandard1.3名字对象中导入net462框架,将允许找到System.IO.Ports.SerialPort对象,但它不会。

在定位.NET Core或.NET Standard时,您无法引用System.IO.Ports.SerialPort,因为此合约仅存在于完整的.NET桌面框架中。

此库最终可能是ported,但与此同时,您必须使用.NET Desktop(例如net462)而不是.NET Core。

删除netcoreapp1.0netstandard1.3并添加net462,它应该有效。

答案 1 :(得分:2)

如果您计划部署到Windows框并定位foreach ( $msg in $msgs ) { #Extra logic here - check message body for search string etc... $source.ReceiveById($msg.Id, [timespan]::FromMinutes(1)) } ,那么只需依赖cucumber (+options) | tee -a logFile.txt 。我整理了一个migration guide来分享我的升级经验,也许它可能有所帮助?我最初有这种误解,我会依赖net452然后net452,David Fowler嘲笑我并且说了一些“伙计做错了!”。 :P

您应该将netstandard1.*更改为:

"import": "net4*"