{"id":22138,"date":"2014-12-17T14:24:26","date_gmt":"2014-12-17T21:24:26","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/aspnet\/?p=22138"},"modified":"2014-12-17T14:24:26","modified_gmt":"2014-12-17T21:24:26","slug":"yeoman-generators-for-asp-net-5","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/yeoman-generators-for-asp-net-5\/","title":{"rendered":"Yeoman generators for ASP.NET 5"},"content":{"rendered":"<p>Hi everyone, this post is in my name but it\u2019s authored by Sourabh Shirhatti. He was a **Program Manager Intern **from the University of Texas at Austin that I\u2019ve had the pleasure of working with this summer. This post is long overdue, we should have posted this a while back. Better late than never \ud83d\ude42<\/p>\n<p>\u00a0<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/63\/56\/metablogapi\/7356.yogif_3789A694.gif\"><img decoding=\"async\" title=\"yo-gif\" style=\"float: none;margin-left: auto;margin-right: auto\" alt=\"yo-gif\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Blogs.Components.WeblogFiles\/00\/00\/00\/63\/56\/metablogapi\/3821.yogif_thumb_2C1894AA.gif\" width=\"570\" height=\"450\" \/><\/a><\/p>\n<p>Building complex modern web applications used to be difficult because of the lack of tooling to maintain and develop client-side code. Recent Open Source projects have made it easier to manage complex client-side code. Writing Coffeescript\/Typescript has made Javascript more manageable. Likewise, SASS\/LESS have alleviated many of the pain points of CSS.<\/p>\n<p>However, this has resulted in a more involved build process to prepare an application for deployment. In addition to compiling your Coffeescript and SASS, readying an application for deployment involves bundling and minification of CSS, minification and possibly inlining of Javascript among other tasks.<\/p>\n<p>Task runners like <a href=\"http:\/\/gruntjs.com\/\">Grunt<\/a> and <a href=\"http:\/\/gulpjs.com\/\">Gulp<\/a> can help perform most of the the mundane work for you after you&#8217;ve configured them, but configuring them is no trivial task. Take a look at <a href=\"https:\/\/github.com\/angular-app\/angular-app\/blob\/master\/client\/gruntFile.js\">a sample GruntFile<\/a><\/p>\n<p>Additionally, package managers like <code>npm<\/code> and <code>bower<\/code> help manage dependencies for increasingly complex client-side code.<\/p>\n<p>Setting up all these tasks for every new project can be a daunting task. That&#8217;s where <a href=\"https:\/\/camo.githubusercontent.com\/8afea7b474cbfbd1609035d5a712c39585f4b1c5\/687474703a2f2f6769616e742e6766796361742e636f6d2f43726565707943616e646964426963686f6e66726973652e676966\">yeoman<\/a> comes in handy.<\/p>\n<blockquote>\n<p><a href=\"http:\/\/www.hanselman.com\/blog\/IntroducingGulpGruntBowerAndNpmSupportForVisualStudio.aspx\">Introducing Gulp, Grunt, Bower, and npm support for Visual Studio<\/a> is a good read about task runner support in Visual Studio<\/p>\n<\/blockquote>\n<h3>What&#8217;s yeoman?<\/h3>\n<p>Yeoman is a client-side stack of tools that help building web applications. The Yeoman workflow is comprised of three tools:<\/p>\n<ol>\n<li>a scafolding tool (yo) <\/li>\n<li>a task-runner\/build tool (Grunt, Gulp); and <\/li>\n<li>a package manager (Bower, npm) <\/li>\n<\/ol>\n<p>According to the <a href=\"http:\/\/yeoman.io\/\">yeoman homepage<\/a>, &#8220;Yeoman helps you kickstart new projects, prescribing best practices and tools to help you stay productive&#8221;.<\/p>\n<p>\u00a0<\/p>\n<h3>What&#8217;s yo?<\/h3>\n<p>As the Yeoman website succintly puts it, &#8220;yo scaffolds out a new application, writing your Grunt configuration and pulling in relevant Grunt tasks and Bower dependencies that you might need for your build.&#8221;<\/p>\n<p>\u00a0<\/p>\n<h3>Why do we care about yeoman?<\/h3>\n<p>Yeoman runs as a command-line interface written in Node.js providing cross-platform support for Mac, Windows and Linux. A Yeoman generator for ASP.NET 5 emphasizes our continued effort to enable cross-platform development of ASP.NET.<\/p>\n<p>\u00a0<\/p>\n<h3>How do I get started with Yeoman?<\/h3>\n<p><u>Install Node.js <\/u><\/p>\n<ol>\n<li>\n<p>Since yeoman runs on Node.js, you can get started by installing the binaries from the <a href=\"http:\/\/nodejs.org\/download\/\">Node.js website<\/a> or using a package manager (<code>brew<\/code>, <code>apt-get<\/code>, <code>yum<\/code>, etc).<\/p>\n<blockquote>\n<p>Note: You might want to install <code>nodejs-legacy<\/code> on Debian systems to prevent conflicts with Amateur Packet Radio <code>node<\/code> Program<\/p>\n<\/blockquote>\n<\/li>\n<\/ol>\n<h4>OSX \/ Linux<\/h4>\n<p>In a terminal you can execute the following command.<\/p>\n<p class=\"brush: bash;\" style=\"font-family:monospace\">\n  if (if ! (which node &gt; \/dev\/null); then echo &#8220;Node.js not found&#8221;; fi &amp;&amp; if ! (which npm &gt; \/dev\/null); then echo &#8220;npm not found&#8221;; fi) then echo &#8220;Looks like you have both Node.js and npm installed&#8221;; fi\n<\/p>\n<p>\u00a0<\/p>\n<h4>Windows<\/h4>\n<p>In a PowerShell prompt you can execute the following command.<\/p>\n<p class=\"brush: bash;\" style=\"font-family:monospace\">\n  if(!(get-command node -ErrorAction SilentlyContinue)){&#8216;node not found&#8217; | Write-Error } if(!(get-command npm -ErrorAction SilentlyContinue)){&#8216;node not found&#8217; | Write-Error }\n<\/p>\n<p><u>**Install <code>yo<\/code> **<\/u><\/p>\n<ol>\n<li>\n<p>Let&#8217;s use npm to install <strong>yo<\/strong> as well as the <strong>ASP.NET 5 generator<\/strong> using the following command<\/p>\n<pre><code>npm install -g yo generator-aspnet\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>How do I scaffold a new ASP.NET 5 application?<\/h3>\n<p>To get started with the Yeoman generator for ASP.NET, launch a Terminal (or powershell) window and type the following command<\/p>\n<pre class=\"brush: bash;\">$ yo aspnet<\/pre>\n<p>You should see a response similar to the following.<\/p>\n<pre class=\"brush: bash;\">_-----_\n    |       |    .--------------------------.\n    |--(o)--|    |      Welcome to the      |\n   `---------\u00b4   |    marvellous ASP.NET    |\n    ( _\u00b4U`_ )    |        generator!        |\n    \/___A___\\    '--------------------------'\n     |  ~  |     \n   __'.___.'__   \n \u00b4   `  |\u00b0 \u00b4 Y ` \n\n? What type of application do you want to create? (Use arrow keys)\n\u276f Console Application \n  Web Application \n  MVC Application \n  Nancy ASP.NET Application <\/pre>\n<p>You can use the arrow keys to select a template type. In this article I will be creating a <strong>MVC Application<\/strong>.<\/p>\n<p>Next, you will be prompted to name your application<\/p>\n<pre class=\"brush: bash;\">[?] What's the name of your ASP.NET application? (MvcApplication1)<\/pre>\n<p>I am going to use the default name <code>MvcApplication1<\/code>, but you are free to rename your application.<\/p>\n<p>On proceeding, the generator will create an empty application the following layout<\/p>\n<pre class=\"brush: bash;\">.\n\u251c\u2500\u2500 MvcApplication1\n\u2502   \u251c\u2500\u2500 Controllers\n\u2502   \u2502   \u2514\u2500\u2500 HomeController.cs\n\u2502   \u251c\u2500\u2500 Models\n\u2502   \u2502   \u2514\u2500\u2500 User.cs\n\u2502   \u251c\u2500\u2500 Startup.cs\n\u2502   \u251c\u2500\u2500 Views\n\u2502   \u2502   \u251c\u2500\u2500 Home\n\u2502   \u2502   \u2502   \u2514\u2500\u2500 Index.cshtml\n\u2502   \u2502   \u2514\u2500\u2500 Shared\n\u2502   \u2502       \u2514\u2500\u2500 _Layout.cshtml\n\u2502   \u2514\u2500\u2500 project.json\n\u2514\u2500\u2500 NuGet.config\n\n6 directories, 7 files<\/pre>\n<pre class=\"brush: bash;\">Note you may want to install <a href=\"https:\/\/github.com\/aspnet\/home#getting-started\">ASP.NET 5 runtime<\/a> to get the command line tools.<\/pre>\n<p>\u00a0<\/p>\n<h3>How do I contribute to this project?<\/h3>\n<p>This project is hosted on GitHub at <a href=\"https:\/\/github.com\/OmniSharp\/generator-aspnet\">omnisharp\/generator-aspnet<\/a> and we accept pull requests from the community.<\/p>\n<p>Sourabh Shirhatti<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone, this post is in my name but it\u2019s authored by Sourabh Shirhatti. He was a **Program Manager Intern **from the University of Texas at Austin that I\u2019ve had the pleasure of working with this summer. This post is long overdue, we should have posted this a while back. Better late than never \ud83d\ude42 [&hellip;]<\/p>\n","protected":false},"author":357,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[9,30,107,117],"class_list":["post-22138","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-net-core","tag-announcement","tag-open-source","tag-releases"],"acf":[],"blog_post_summary":"<p>Hi everyone, this post is in my name but it\u2019s authored by Sourabh Shirhatti. He was a **Program Manager Intern **from the University of Texas at Austin that I\u2019ve had the pleasure of working with this summer. This post is long overdue, we should have posted this a while back. Better late than never \ud83d\ude42 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/22138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/357"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=22138"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/22138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=22138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=22138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=22138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}