« Back to home

ASP.NET vNext on OSX

Posted on

I recently purchased a MacBook Air so I can work on projects when on the road. With the recent updates to ASP.NET and being available on all platforms (Windows, OSX, Linux), I wanted to bring the same development experience on the OSX (currently on Yosemite).

This post will provide a quick start on being able to write ASP.NET vNext apps on OSX.


I started by bringing in the KVM (K Version Manager) which is used to build and run ASP.NET provided on this link. KVM is used to manage and get the runtime (KRE - K Runtime Environment) for .NET.

The way to bring this in is to use Homebrew which is a package manager for OSX much like Chocolatey is for Windows.

Installing OmniSharp

The next step is to install Sublime Text 3 if you don't have this app yet. Once you have the text editor, the final step is to install OmniSharp which is an open source cross platform project that brings in Intellisense and code completion to Sublime, Vim, Atom, etc. This gives you the ability to be productive much like being in the Visual Studio environment when developing in ASP.NET/C#.

Omnisharp brings in multiple projects with each specific to a text editor. One of which is Kulture which is a project for Sublime. I personally had an issue finding the package control plugin (cmd+shift+p) to install Kulture in Sublime highlighted here.

If the package control doesn't come up, launch the Sublime console by typing ctrl+[back tick] then paste this in (credit to this site).

import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)  

Creating an ASP.NET app

Lastly, we will bring in Yeoman using NPM (node package manager) which is a command line tool to quickly generate an application.

npm install -g yo

The next command is to bring in the node modules to generate the actual ASPNET app.

npm install -g generator-aspnet

After installing Yeoman, we can then create the app by:

yo aspnet

This basically initiates the app creation process and asks basic questions such as the name of the app and the type of web application that you're building (ie MVC, Web Application, etc.)

Quick Sublime commands

To bring in the Sublime command palette, use (cmd+shift+p) then select Run K Commands or F5 to bring in the k and kpm stuff which are quick access to commands to run the server (k kestrel), restore packages (kpm restore), etc.

After generating the new project, the first thing is to restore packages which was mentioned above. After that finishes, to build the project (cmd+b) to make sure that there's no error.

Finally, run the app using the k kestrel (OSX specific) command in the command pallette then browse localhost:5004 in your browser to view the ASP.NET application.


comments powered by Disqus