A new feature has been added to the ASP. NET 5 Beta2 (see ASP. 5 Beta2 release), and you can generate MVC code with the K command, such as K Gen Controller-name HomeController.
If you are using Visual Studio, you naturally disagree with this feature because Visual Studio helped you do it.
If you're using a Mac, no Visual Studio, and no K studio, and you don't want to self-abuse the MVC code generated by the template, this feature deserves attention.
Because the MAC writes ASP. NET code for a long time, discover this feature, immediately want to try. But there is no relevant information on the Internet, can only explore their own.
first in Project.json's dependencies Change all 1.0.0-beta1 to 1.0.0-beta2, which is the package that is upgraded to ASP. NET 5 Beta2.
{" dependencies": { "Microsoft.AspNet.Server.IIS": "1.0.0-beta2", " Microsoft.AspNet.Diagnostics ":" 1.0.0-beta2 ", " Microsoft.AspNet.Hosting ":" 1.0.0-beta2 ", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta2", "Microsoft.AspNet.StaticFiles": " 1.0.0-beta2 " }}
the next step is to add gen function (K gen) to K, Add the following configuration to Project.json's commands and tell K to find this command in the Microsoft.Framework.CodeGeneration package:
{" commands": { "gen": "Microsoft.Framework.CodeGeneration" }}
The next step is to download the Microsoft.Framework.CodeGeneration package, which is KPM dry work, add references in Project.json dependencies, and run KPM restore:
{ "dependencies": { "Microsoft.Framework.CodeGeneration": "1.0.0-beta2" }}
KPM Restore
The original thought this is done, the result of running K gen Controller-name homecontroller error message:
' Controller '
So stuck here, almost give up.
Later, think of a special package for the controller's code generation, on GitHub to browse the ASP. Repo List found an east:
Scaffolding-code generators to speed up development
Maybe this job is scaffolding. See a blog link on the ASP.--how to customize scaffolding templates for ASP. Scaffolding, after reading this blog post, The original controller's code generation is MICROSOFT.FRAMEWORK.CODEGENERATORS.MVC responsible.
Then, add the MICROSOFT.FRAMEWORK.CODEGENERATORS.MVC in the Project.json dependencies:
{ "dependencies": { "Microsoft.Framework.CodeGeneration": "1.0.0-beta2", " MICROSOFT.FRAMEWORK.CODEGENERATORS.MVC""1.0.0-beta2" }}
Then KPM restore, the result nuget/myget server jerks, restore an afternoon plus night, until the 2nd day of the morning to restore success.
Then run the K gen Controller-name HomeController , and it succeeds:
6.0.0-* to the application.
K Gen code generation in Mac that experiences ASP. NET 5 Beta2