无法执行命令dnx web

时间:2016-04-18 11:53:00

标签: asp.net asp.net-core dnx kestrel-http-server asp.net5

出于某种原因,我无法使用DNX和Kestrel运行简单的,开箱即用的ASP.NET 5 / Core 1.0 Web应用程序。运行dnx web后,我不断收到错误:

Error: Unable to load application or execute command 'Microsoft.AspNet.Server.Kestrel'. Available commands: web, ef.

我的project.json:

{
  "version": "1.0.0-*",
  "userSecretsId": "aspnet5-WebApplication-635604fe-13b8-4779-8e12-35ec067b73ae",
  "compilationOptions": {
    "emitEntryPoint": true
  },
  "tooling": {
    "defaultNamespace": "WebApplication"
  },

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Sqlite": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "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.Dnx.Runtime":"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"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [
      "npm install",
      "bower install",
      "gulp clean",
      "gulp min"
    ]
  }
}

是的,我之前已经开过dnu restore。我安装了这些运行时:

dnx-clr-win-x64.1.0.0-rc1-update1
dnx-clr-win-x64.1.0.0-rc1-update2
dnx-clr-win-x86.1.0.0-rc1-update1
dnx-clr-win-x86.1.0.0-rc1-update2
dnx-coreclr-win-x64.1.0.0-rc1-update2

我真的希望有人知道这个问题可能来自哪里。

更新

我似乎遇到了解决依赖关系和程序集绑定的问题。每当我运行dnu build它构建得很好,我可以看到所有nuget包依赖关系在C:\ users \ ***** \ .dnx \ packages中解析/恢复。

然而,在运行dnx web时,我不断收到我提到的错误。我启用了FusionLog,似乎现在还没有解决早期的nuget包依赖项。我一直遇到这样的错误:

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
   at WebApplication.Startup.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\*****\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update2\bin\dnx.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
 (Fully-specified)
LOG: Appbase = file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.AspNet.Hosting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: Fusion is hosted. Check host about this assembly.
LOG: Try host assembly store with assembly microsoft.aspnet.hosting, version=1.0.0.0, culture=neutral, publickeytoken=adb9793829ddae60, processorarchitecture=x86.
LOG: Try host assembly store with assembly microsoft.aspnet.hosting, version=1.0.0.0, culture=neutral, publickeytoken=adb9793829ddae60, processorarchitecture=msil.
LOG: Try host assembly store with assembly microsoft.aspnet.hosting, version=1.0.0.0, culture=neutral, publickeytoken=adb9793829ddae60.
WRN: Host assembly store does not contain this assembly.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting.DLL.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting/Microsoft.AspNet.Hosting.DLL.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting.EXE.
LOG: Attempting download of new URL file:///C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/Microsoft.AspNet.Hosting/Microsoft.AspNet.Hosting.EXE.

所以我现在知道问题所在。如果我暂时将所需的dll复制到/C:/Users/*****/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin,它似乎可以解决,但这不是解决方案。

更新2

似乎问题是clr运行时。每当我通过输入cmd dnvm use 1.0.0-rc1-update1 -a x86 -r coreclr后跟dnx web来使用coreclr时,该应用程序运行正常。

我尝试重新安装clr,同时为x64和x86安装update1和update2,但错误仍然存​​在。只有coreclr似乎有效。任何人的想法?

0 个答案:

没有答案