Dec 30 2015

Creating a yeoman generator

  1. Create a directory.  Open a node command prompt to that directory.
  2. Create a node project...
    npm init
  3. Install the base yeoman packages...
    npm install yeoman-generator --save (save adds dependencies to our node project).
  4. Add a folder called "app".
  5. In that folder add a file called "index.js".
  6. put your generator code in the index.js file... like this...
    'use strict'

    var generators = require('yeoman-generator');

    module.exports = generators.Base.extend({
    method1: function(){
    this.log('Hello, World!');
    }
    });

  7. Create a symlink to your current directory for npm using this command...
    npm link (this enables the running of the generator)
Dec 30 2015

Using Yeoman to scaffold asp.net mvc applications

  1. Install nodejs
  2. From the node command prompt install yeoman ... npm  install -g yo
  3. You may want to install any dependencies that will be used by yeoman like...
    npm install -g gulp
    npm install -g bower
    npm install -g grunt
    npm install -g grunt-cli
  4. Install a yeoman generator...for example
    npm install -g generator-aspnet
    or (for a plain vanilla website)
    npm install -g generator-webapp
  5. Create and navigate to the target directory where you want to create your aspnet web app.
  6. run a yeoman generator as follows...
    yo aspnet
    or
    yo (then select your generator from the list)
  7. When you run the aspnet generator you will be prompted to name your web app...name it.
  8. The navigator will create a folder matching your app name...navigate into that folder (cd <appname>)
  9. To create a dotnet runtime environment for your app type...
    dnu restore
    If you get a dnu command not found error ... from another admin cmd type ...
    dnvm upgrade...
    If that command doesn't work see this page...
    https://github.com/aspnet/home/
  10. To launch the web server type dnx web
  11. To get help on a generator type yo <generatorname> --help...like this...
    yo aspnet  --help
  12. This will show you all of the  sub-generators for the generator
    1. To get help on a subgenerator type yo <generator>:<subgen> --help ... like this...
      yo aspnet:TypeScript --help
      or
      yo aspnet:MvcController --help
  13. So..to generator a new controller do yo aspnet:MvcController <controllername>...like this...
    yo aspnet:MvcController HelpController
  14. To create a matching view for an action you can use aspnet:MvcView <viewname>...BUT...
    first you have to navigate to the views folder (cd views) create a target folder that matches the controller name ... like "Help" and then navigate to that folder.

For more information on this, including how it all works beautifully with visual studio code see this...
https://code.visualstudio.com/Docs/runtimes/ASPnet5