如何在ASP.NET 5中使用"旧"依赖项

mat*_*wen 6 asp.net-core

我使用干净安装的VS 2015 Enterprise RC1创建了一个新项目,我正在尝试为Mandrill添加一个针对.NET 4构建的Nuget包.

当我构建项目时,我从DNX Core 5.0收到错误,找不到命名空间:

All packages are already installed and there is nothing to restore.
NuGet package restore finished.
1>------ Build started: Project: WebApplication3, Configuration: Debug Any CPU ------
1>C:\Projects\WebApplication3\src\WebApplication3\MessageServices.cs(5,7,5,15): DNX Core 5.0 error CS0246: The type or namespace name 'Mandrill' could not be found (are you missing a using directive or an assembly reference?)
1>
1>  Build failed.
1>           0 Warning(s).
1>           1 Error(s).
1>
1>  Time elapsed 00:00:00.1404086
1>
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)

我没有添加为全局依赖,而是尝试将其添加到dnx451框架中project.json,结果相同.

"frameworks": {
    "dnx451": {
        "dependencies": {
            "Mandrill": "1.3.1"
        }
    },
    "dnxcore50": { }
},
Run Code Online (Sandbox Code Playgroud)

甚至可以在ASP.NET 5中使用.NET 4包吗?如果是这样,需要什么?

Vic*_*aci 11

Mandrill软件包可能不支持CoreCLR.您有两种选择:

  1. 通过删除中的dnxcore50部分,从包中删除对CoreCLR的支持project.json
  2. 使用条件编译并排除对Mandrillapi 的调用.示例:#if DXNCORE50 ...#if DNX451