空控制器的 DNX 代码生成抛出方法未找到异常

DNX Codegeneration for empty controller throws Method not found exception

我正在为我的应用程序使用带有 DNX 1.0.0-beta6 的 VS2015,并尝试使用命令行代码生成来生成一个空控制器,但遇到以下错误。需要帮助。

d:\Project>dnx . gen controller -name PersonController
Finding the generator 'controller'...
Running the generator 'controller'...
Method not found: 'Microsoft.AspNet.Razor.GeneratorResults Microsoft.AspNet.Razor.RazorTemplateEngine.GenerateCode(System.IO.TextReader)'

我的project.json看起来像这样

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",
  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta6",
    "Microsoft.AspNet.Mvc": "6.0.0-beta6",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta6",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta6",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta6",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta6",
    "Microsoft.Framework.Logging": "1.0.0-beta6",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta6",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta6",
    "EntityFramework.Core": "7.0.0-beta6",
    "EntityFramework.Commands": "7.0.0-beta6",
    "EntityFramework.SqlServer": "7.0.0-beta6",
    "Microsoft.Framework.CodeGeneration": "1.0.0-beta5",
    "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5"
  },
  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "gen": "Microsoft.Framework.CodeGeneration",
    "ef": "EntityFramework.Commands"
  },
  "frameworks": {
    "dnx451": {
      "dependencies": {
        "EntityFramework.Core": "7.0.0-beta5"
      }
    },
    "dnxcore50": { }
  },
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }
}

您不能使用 Microsoft.Framework.CodeGenerationMicrosoft.Framework.CodeGenerators.Mvcbeta5,因为它们依赖于 beta5 基础架构,这会与您拥有的其他依赖项发生冲突。

此时这些软件包的 beta6 尚未发布或发布。

有一个 github 问题跟踪:

https://github.com/aspnet/Scaffolding/issues/105

回答这个问题后,我们就会知道它是否会得到修复。

目前,要使用脚手架,您必须返回 beta5

更新: 另一种选择是使用 aspnetmaster 提要:https://www.myget.org/gallery/aspnetmaster