2

I have the following project.json file...

{
  "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"
  ]
}

I am trying now to do some MVC 6 Controller Scaffolding in command line but after executing the command:

dnx gen controller -name ClassController --dataContext RegistrationDbContext --model Class

However, I am getting the following error message... EDIT: This is the message that I am getting after installing Microsoft.Framework.CodeGeneration package (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)

Any pointers? How can I fix that?

In any case, this is my global.json too..

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

Thanks!

user3587624
  • 1,427
  • 5
  • 29
  • 60
  • 1
    I would recommend moving your app to rc1 first. There was already 4 releases after beta-5 so it's not likely you will get an answer for your question (and, if it was a bug, it might have been fixed already). – Pawel Dec 02 '15 at 04:52
  • How can I move my whole app to rc1? Seems like by default everything is trying to be set to beta5. Also, are all the dependencies that I set in my json file available in rc1? Thanks! EDIT. Seems like there is an update for my VS 2015 that is about Microsoft ASP.NET 5 RC1 Update 1. Maybe that would allow me to move to rc1? – user3587624 Dec 02 '15 at 04:54
  • 1
    First, update tooling - for each runtime release there is a new tooling release. If new projects are created for beta-5 it means that you have ancient tooling. Then update references to 1.0.0-rc1-final. You can now get the latest bits from https://get.asp.net/ – Pawel Dec 02 '15 at 04:56
  • Got it! That's what I suspected just right now! I edited it my previous comment while you added this one :) Thanks! – user3587624 Dec 02 '15 at 04:57

1 Answers1

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

Tamayi
  • 143
  • 4