简体   繁体   English

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

[英]Dependency issues migrating project from ASP.NET 5 RC1 to ASP.NET Core 1.0

I am having a hard time converting my asp.net (core) app from dnx46 to .netcoreapp1.0 because of two particular dependencies ( Microsoft.Azure.ServiceBus and System.IO.Ports.SerialPort ) 由于两个特定的依赖项( Microsoft.Azure.ServiceBusSystem.IO.Ports.SerialPort ),我很难将我的asp.net(核心)应用程序从dnx46转换.netcoreapp1.0

Being positive, I'm making the bet that these feature will eventually land on .net core one day.. but in the meantime, I found that converting my app from moniker dnx46 to .netstandard1.3 allows me to resolve the ServiceBus dependency. 可以肯定的是,我敢打赌这些功能最终有一天会落在.net核心上。但是与此同时,我发现将我的应用程序从名字dnx46转换为.netstandard1.3可以解决ServiceBus依赖性。

Resolving System.IO.Ports.SerialPort however is still an issue and I don't understand how to make this work. 但是,解决System.IO.Ports.SerialPort仍然是一个问题,我不知道如何实现此目的。 I was hoping that importing net462 framework in .netstandard1.3 moniker, would allow to find the System.IO.Ports.SerialPort object but it does not. 我希望在.netstandard1.3名称中导入net462框架将允许找到System.IO.Ports.SerialPort对象,但没有找到。

What am I missing ? 我想念什么?

For reference, there's my project.json : 供参考,这是我的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",
      }
    }
  }
}

Resolving System.IO.Ports.SerialPort however is still an issue and I don't understand how to make this work. 但是,解决System.IO.Ports.SerialPort仍然是一个问题,我不知道如何实现此目的。 I was hoping that importing net462 framework in .netstandard1.3 moniker, would allow to find the System.IO.Ports.SerialPort object but it does not. 我希望在.netstandard1.3名称中导入net462框架将允许找到System.IO.Ports.SerialPort对象,但没有找到。

You can't reference System.IO.Ports.SerialPort when targeting .NET Core or .NET Standard, because this contract only exists in the full .NET Desktop framework. 面向.NET Core或.NET Standard时,不能引用System.IO.Ports.SerialPort ,因为此合同仅存在于完整的.NET Desktop框架中。

This library might be eventually ported but in the meantime, you'll have to use .NET Desktop (eg net462 ) instead of .NET Core. 该库可能最终会被移植,但是与此同时,您必须使用.NET Desktop(例如net462 )而不是.NET Core。

Remove netcoreapp1.0 and netstandard1.3 and add net462 and it should work. 删除netcoreapp1.0netstandard1.3并添加net462 ,它应该可以工作。

If you plan on deploying to a windows box and targeting net452 , then simply take on a dependency on net452 . 如果您打算部署到Windows框并定位到net452 ,则只需依赖net452 I put together a migration guide to share my upgrading experiences, perhaps it might help? 我整理了一份迁移指南以分享我的升级经验,也许可能会有帮助? I initially had this misunderstanding that I would take a dependency of netstandard1.* and then "import": "net4*" , David Fowler laughed at me and said something to the extent of "dude that's do wrong!". 最初我有这样的误解,我会先依赖netstandard1.* ,然后再依赖"import": "net4*" ,David Fowler嘲笑我,并说了些“不对劲!”。 :P :P

You should change your project.json frameworks to look like this: 您应该将project.json frameworks更改为如下所示:

"frameworks": {
    "net462": { }
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM