In the previous articles we have seen some brand new features in ASP.NET Core. ASP.NET core is the open source , cross platform and lightweight framework to build web application . It can be built and run on Windows , Mac and Linux. In this article I will explain how to generate ASP.NET Core application using Yeoman generator.
What is Yeoman ?
Sub generators are used to generate new items like views, controllers into ASP.NET project.
Install NPM , Yeoman and ASP.NET core generator
NPM (Node Package Manager) is used to install Yeoman . You can download this from npmjs.com for any platform. I got the windows version from Nodejs.org . After installing NPM, go to command line and enter the following command to install Yeoman.
npm install yo -g
After this , install the ASP.NET core generator using the following commands .
npm install generator-aspnet -g
Create ASP.NET Core Application using Yeoman generator
Type command yo aspnet after installing NPM , Yeoman and ASP.NET generator . This will ask for the type of the application which you want to create .
Select Web Application to generate ASP.NET core application and enter the name . This will create a brand new ASP.NET core project for you. After this you need to perform 3 operations. Rest the DNU ( recommended for first time ) , build the application ( optional ) and run the application using following commands.
dnu restore dnu build dnx web eg: C:\Users\Tom\yotestprj>dnx web
In the command line you will get the URL for our newly created web application. Copy and past it in a browser, then you can see the new ASP.NET core application.
Create sub generator for the ASP.NET Core
In the previous section we have created the web application with a template which is similar to the template from Visual studio. As I mentioned earlier , sub generators are used to create new items in the exiting application like ‘add new controller’ . Execute the following command to create a controller .
yo aspnet:MvcController MyYoController
Latest posts by Tom Mohan (see all)
- How to choose a WCF binding ? - January 29, 2017
- Get free Azure trial worth ₹50,000 and Azure webinar series . - September 3, 2016
- .NET core : Build and run in any platform. - August 7, 2016