Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Creating ASP.NET 5 Web Application Using Yeoman Generator

DZone's Guide to

Creating ASP.NET 5 Web Application Using Yeoman Generator

Free Resource

Get deep insight into Node.js applications with real-time metrics, CPU profiling, and heap snapshots with N|Solid from NodeSource. Learn more.

In this post we will explore Yeoman generator that helps to scaffold ASP.NET 5 web application using command line statements. What is Yeoman? Yeoman is a set of tools that facilitates building web applications. It comprises of three tools

  • yo (scaffolding template tool)
  • task runner/build tool (Grunt, Gulp)
  • package manager (Bower, npm)

In this post I will focus on yo tool that can be used to generate scaffolding template for aspnet web applications. This tool can be used in environments where you don’t have a Visual Studio 2015 installed or you wanted to scaffold web application using yo command. Yeoman generator for ASP.NET 5 emphasizes to continued effort to enable cross-platform development of ASP.NET It is available for Windows, Linux and OSX operating systems. First of all, configure the ASP.NET 5 environment on your machine.

  1. The easiest way to get started on windows is to install Visual Studio 2015. Visual studio 2015 installs the DNVM (Dot NET Version Manager) command line tool to manage DNX (Dot Net Execution environment) versions and much more.
  2. If you don’t want to install Visual Studio 2015 you can even run this Power shell command to install DNVM{$Branch=’dev';iex ((new-object net.webclient).DownloadString(‘https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1′))}
  3. This command will install the DNVM and the latest DNX version available at NuGet.org.
  4. Now run following command to list the version of DNX installed on your system

C:\dnvm list+


Once ASP.NET 5 environment is setup, develop a simple ASP.NET 5 web application using Yeoman generator.

5. First of all install the yeoman generator using this command npm install –g yo generator-aspnet


6.  Now run yo aspnet to create ASP.NET 5 web application 


7. You can select any template using top/down arrow keys

8. Let’s select 3rd template type i.e. Web Application and press Enter

9. It will ask you to specify the name 


10.Specify any name and press enter 


11. You can see the project is created, now go to the folder as I created on root C drive and my web application project  name was TestBlogPost so I found the folder created as TestBlogPost inside c drive root.

12. Now browse your folder and open project.json file, you will see bunch of packages specified there

13. Run kpm restore to restore the packages and then kpm build to build the web application 


14. Run dnx . web finally to run the web server 


15. Now browse to http://localhost:5000 address, you will see the ASP.NET 5 home page as below. (You can see the URL from project.json configured for web command)



Node.js application metrics sent directly to any statsd-compliant system. Get N|Solid

Topics:
yeoman ,asp.net ,html5

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}