2

次の project.json ファイルがあります...

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

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-beta5",
    "EntityFramework.SqlServer": "7.0.0-beta5",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta5",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta5",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta5",
    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta5"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "ef": "EntityFramework.Commands",
    "gen": "Microsoft.Framework.CodeGeneration"
  },

  "frameworks": {
    "dnx451": {
      "frameworkAssemblies": {
        "System.Data": "4.0.0.0"
      }
    },
    "dnxcore50": { }
  },

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

コマンドラインでMVC 6コントローラースキャフォールディングを実行しようとしていますが、コマンドを実行した後:

dnx gen controller -name ClassController --dataContext RegistrationDbContext --model クラス

ただし、次のエラー メッセージが表示されます... 編集: これは、 Microsoft.Framework.CodeGeneration パッケージ ( Install-Package Microsoft.Framework.CodeGeneration -Pre )をインストールした後に表示されるメッセージです。

System.InvalidOperationException: Unable to resolve service for type 'Microsoft.Framework.Runtime.ILibraryManager' while attempting to activate 'Microsoft.Framework.CodeGeneration.DefaultCodeGeneratorAssemblyProvider'.
   at Microsoft.Framework.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Framework.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.Framework.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProviderprovider, Object[] parameters)
   at Microsoft.Framework.CodeGeneration.ServiceProvider.AddServiceWithDependencies[TService,TImplementation]()
   at Microsoft.Framework.CodeGeneration.Program.AddCodeGenerationServices(ServiceProvider serviceProvider)
   at Microsoft.Framework.CodeGeneration.Program..ctor(IServiceProvider serviceProvider)

ポインタはありますか?どうすれば修正できますか?

いずれにせよ、これは私のglobal.jsonでもあります..

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-beta5",
    "runtime": "clr",
    "architecture": "x64"
  }
}

ありがとう!

4

1 に答える 1

1

In rc1-final, the namespaces have changed :

FROM: Microsoft.Framework.CodeGeneration

TO: Microsoft.Extensions.CodeGeneration

project.json

  "dependencies": {
    ...
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
 }

  "commands": {
    ...
    "gen": "Microsoft.Extensions.CodeGeneration"
  }

To customize the MVC6 scaffolding templates, you will find them in the folder: C:\Users\{user}\.dnx\packages\Microsoft.Extensions.CodeGenerators.Mvc\1.0.0-rc1-final\Templates

Use dnx gen controller --help to get some help on the parameters

于 2016-03-04T16:18:13.633 に答える