运行 Asp.net 5 vNext 项目 (MVC6) 在 Windows Server 2012 R2 上发布构建

Run Asp.net 5 vNext project (MVC6) publish build on Windows Server 2012 R2

我根据互联网上的一些资源配置了一切,但我不知道我错过了什么..

当我尝试手动启动它时(这在我的本地计算机上有效!)我在服务器上得到以下结果:

PS C:\Users\Administrator> cd C:\inetpub\wwwroot\approot\myproject\approot
PS C:\inetpub\wwwroot\approot\myproject\approot> .\web
Error: Unable to load application or execute command 'Microsoft.AspNet.Hosting'. Available commands: web, kestrel.
System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
   at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
   at System.Reflection.Assembly.LoadFile(String path)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath)
   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContex
t)
   at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

在 Windows Server 2012 上完成的事情:

  1. 已安装DNVM/DNX
  2. 已启用的功能 IIS 和应用程序服务器(选定的 Web 服务器 (IIS) 也支持应用程序服务器)
  3. .Net 4.5.2 已安装。

DNVM 列表输出:

Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
       1.0.0-rc1-update1 clr     x86          win             default

与我的项目和本地计算机中使用的相同。

我还从 IIS 寻找 stdout.log,因为我也尝试用 iis 设置它。但没有运气。并且没有创建或找不到日志。

备案 project.json

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
    "Swashbuckle.SwaggerUi": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
    "kestrel": "Microsoft.AspNet.Server.Kestrel",
  },


  "frameworks": {
    "dnx451": {
      "dependencies": {
        "Microsoft.AspNet.Mvc.ViewFeatures": "6.0.0-rc1-final",
        "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc1-final"
      }
    },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

如果需要更多信息,请告诉我。

还不确定为什么,因为我认为发布将包含能够 运行 的所有内容。但是..我找到了一个解决方案。

如果您在服务器上的 powershell 中转到 Approot > SRC > ProjectName 文件夹并 运行 dnu 恢复.. web.cmd 将突然起作用!当它加载丢失的包时!