无法使用 'dnx web' 启动 Kestrel,说 "current runtime target framework is not compatible"

Unable to start Kestrel with 'dnx web', says "current runtime target framework is not compatible"

SO上有很多类似的问题,但我找不到解决问题的方法。很明显我对 .NET Core 还不够熟悉... )

我有一个严格的 ASP.NET 核心应用程序,我正在尝试使用 dnx web[=56] 启动 Kestrel 网络服务器=] 命令,但它失败了,因为活动框架目标似乎是 dnx451(而不是 dnxcore50)。

我的global.json看起来像:

 {
   "projects": [ "FolderName", "src", "test" ], // What IS the actual project name?

  "sdk": {
    "version": "1.0.0-rc1-update2",
    "runtime":  "coreclr", 
    "architecture": "x86"
  }
}

摘自project.json

    "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:8000/"
    },

  "frameworks": {
    "dnxcore50": { }
  }

最后,在launchSettings.json:

{
  "profiles": {
    "web": {
      "commandName": "web",
      "launchBrowser": false,
      "launchUrl": "http://localhost:8000",
      "environmentVariables": {
        "Hosting:Environment": "Development"
      },
      "sdkVersion": "dnx-coreclr-win-x86.1.0.0-rc1-update2"
    }
  }
}

据我所知,project.json中的依赖与SDK版本匹配:

"dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
  }

然而,当我 运行 dnx web 我得到以下信息:

System.InvalidOperationException: The current runtime target framework is not compatible with 'Okaymaker.Web'.
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)'
 Version:      1.0.0-rc1-16609
 Type:         Clr
 Architecture: x86
 OS Name:      Windows
 OS Version:   10.0
 Runtime Id:   win10-x86

Please make sure the runtime matches a framework specified in project.json

不确定为什么它说当前目标框架是 dnx451?我想我可以 运行 dnx use before 运行ning dnx web,但我的印象是配置应该为我处理这些设置吗?

这是我看到的 运行 dnvm list:

Active Version           Runtime Architecture Location                         Alias
------ -------           ------- ------------ --------                         -----
       1.0.0-beta8       clr     x64          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-beta8       clr     x86          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-beta8       coreclr x64          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-beta8       coreclr x86          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-rc1-update1 clr     x64          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-rc1-update1 clr     x86          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-rc1-update1 coreclr x64          C:\Users\TedNyberg\.dnx\runtimes
       1.0.0-rc1-update1 coreclr x86          C:\Users\TedNyberg\.dnx\runtimes
  *    1.0.0-rc1-update2 clr     x86          C:\Users\TedNyberg\.dnx\runtimes default
       1.0.0-rc1-update2 coreclr x86          C:\Users\TedNyberg\.dnx\runtimes

编辑: 看来这些问题可以通过安装 Visual Studio 2015 Update 3 resolved/avoided 更新的 .NET Core 工具 ,均位于:https://www.microsoft.com/net/core#windows

您必须使用 dnvm use 将当前运行时设置为 coreclr。 VisualStudio 不够智能,但已发布的脚本足够智能,可以构建一个 shell 脚本来静态 select 正确的引擎。

这是一个已确认的 RC1 设计缺陷(抱歉懒得搜索 ASP.NET Community Standup 的视频笔记)并作为 dotnet 命令行界面的一部分得到修复。