0

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

我有一个严格的 ASP.NET Core 应用程序,我正在尝试使用dnx web命令启动Kestrel Web 服务器,但它失败了,因为似乎活动框架目标是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 web之前运行dnx use,但我的印象是配置应该为我处理设置?

这是我运行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 .NET Core的更新工具来解决/避免这些问题,两者均可在以下网址获得:https ://www.microsoft.com/net/core#windows

4

1 回答 1

0

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

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

于 2016-08-20T10:20:52.020 回答