June 28, 2015

How to create, build and run ASP.NET 5 MVC web application on OS X

Visual Studio Code


  1. Install homebrew
  2. Install ASP.NET 5 on OS X
  3. Generate ASP.NET MVC project
  4. Build web application
  5. Run it

Install Homebrew

$ ruby -e "$(curl -fsSL"

Install ASP.NET 5 on OS X

$ brew tap aspnet/dnx
$ brew install dnvm

Now add source to your /.bash_profile, ~/.bashrc or ~/.zshrc at the end of file

Generate ASP.NET MVC project

Install Node.js if you still don’t have it

$ brew install node

Now install CLI tool for running Yeoman generators

$ npm install -g yo
$ npm install -g generator-aspnet

Navigate to folder where you want to generate ASP.NET 5 Web application and run generator

$ yo aspnet

Specify app name and select Web application

Build web application

ASP.NET 5 uses Bower package manager

$ npm install -g bower

Restore all dependencies

$ dnu restore

Navigate to project root folder where project.json and run build

$ dnu build

Run it

On OS X it’s possible to run ASP.NET application using Kestrel

$ dnx . kestrel

Open browser and navigate to http://localhost:5001

You’ll get exception:

An unhandled exception occurred while processing the request.

IOException: kqueue() FileSystemWatcher has reached the maximum nunmber of files to watch.

This is caused by bug in Mono 4.0.1:

WORKAROUND: Add export MONO_MANAGED_WATCHER=false to your /.bash_profile, ~/.bashrc or ~/.zshrc at the end of file

Re-run application $ dnx . kestrel and refresh page

Congratulations! ASP.NET 5 Web application on OS X

Feel free to ask me any questions in the comments below.

comments powered by Disqus