Creating ASP.NET 5 Web Application using Yeoman Generator

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

1

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

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

2

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

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

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

5. It will ask you to specify the name 4

6.Specify any name and press enter 5

7. 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.

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

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

10. Run dnx . web finally to run the web server 7

11. 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)

0 Hope this helps!

Advertisements

One thought on “Creating ASP.NET 5 Web Application using Yeoman Generator

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s