无法在ASP.NET Core中构建控制器/视图

时间:2016-11-14 12:33:37

标签: asp.net-core asp.net-core-mvc entity-framework-core

当我尝试使用代码生成器添加Scaffold Items时,我收到以下错误消息:

运行生成器时的异常输出:

enter image description here

目前我尝试了很多个小时,但我没有发现失败:(

这是我的project.json文件

{
  "dependencies": {
    "Microsoft.AspNetCore.Authentication": "1.0.0",
    "Microsoft.AspNetCore.Authorization": "1.1.0-*",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0-*",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.1.0-*",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-*",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0-preview1-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.1.0-preview1-final",
    "Microsoft.EntityFrameworkCore.Design": "1.0.1",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0-preview1-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-*",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.1.0-*"
    },
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview3-final",
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": "1.0.0-preview3-final"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview3-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Mvc": "1.0.0-preview3-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.0.0-preview3-final"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

2 个答案:

答案 0 :(得分:0)

您有一个依赖Microsoft.Extensions.CodeGenerators.Mvc和更高版本的Microsoft.VisualStudio.Web.CodeGenerators.Mvc。我认为这与Microsoft.Extensions是错误的。

答案 1 :(得分:0)

我的意思是,你的框架定义不正确。

在您的项目中:

"frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"

检查一下:

"frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      },
      "imports": "dnxcore50"
    }
}

那么可以,你现在可以使用Microsoft.Extensions.CodeGenerators.Mvc作为dnx。