How to install and use Visual Studio Code and ASP.NET 5 on Mac OS X

Visual Studio Code for Mac, Windows and Linux.
Credit: Microsoft

Use command line tools to install, update, run and edit ASP.NET 5 projects on Mac OS X.


Microsoft Build 2015

Yesterday was the first day of Microsoft's Build 2015 conference. Microsoft introduced a plethora of tools designed to help developers create cross platform solutions for the desktop, web, and mobile devices. ASP.NET 5 and Visual Studio Code were among the most interesting technologies mentioned. So, I decided to test using and installing these technologies on a Mac OS X system, running Yosemite version 10.10.3.


Before starting this process yourself, you will need an account on GitHub, and you should probably install the Github for Mac app if you haven't done so already.

Installing ASP.NET 5

To install ASP.NET 5, a tool known as Homebrew first needs to be running and installed on your Mac. Homebrew is the package management tool recommended by the aspnet/Home page on Github to install the .NET Version Manager (DNVM) for Mac OS X. In turn, DNVM is the mechanism employed by Microsoft to provide the most up-to-date builds of the .NET Execution Environment (DNX).

The kind folks at Homebrew made installation a breeze, using only a single line of ruby code:

$ ruby -e "$(curl -fsSL"

Next, use brew to install DNX and DNVM:

$ brew tap aspnet/dnx 
$ brew update
$ brew install dnvm

Although the installation instructions provided on the aspnet page are of excellent quality, it should probably emphasize the two lines that need added to ~/.bash_profile or ~/.bashrc:

export MONO_GAC_PREFIX="/usr/local" source

I used the command line editor pico to edit .bash_profile, inserting the lines where appropriate:

Adding lines to .bash_profile

When finished editing .bash_profile, download DNX:

$ dnvm upgrade

To complete the ASP.Net install, follow the remaining instructions found in the Running the Samples section of the aspnet page.

Installing Visual Studio Code

Download and install Visual Studio Code for Mac OS X following these instructions from Microsoft. If you wish to start VS Code from a command shell, Microsoft recommends appending this code block to ~/.bashrc, but you can also append it to ~/.bash_profile without experiencing difficulties:

code () {
   if [[ $# = 0 ]]
       open -a "Visual Studio Code"
       [[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
       open -a "Visual Studio Code" --args "$F"

Updating source and running VS Code

To test the setup, I opened terminal once more and entered the following commands to update and run the sample ConsoleApp project. (NOTE: For simplicity sake, my ASPNET home repository was placed directly under the Documents folder)

$ cd ~/Documents/home/samples/latest/ConsoleApp
$ dnu restore
$ dnx . run

As expected, this source ran successfully:

Running ASP.Net 5 project from Mac OS X command line

A final test remained, opening the project in Visual Studio Code from the command line.

$ code .

Again success, the project is opened in Visual Studio Code. Notice code completion on a line of source in the editor pane:

Visual Studio Code with code completion.

Have fun, and enjoy ASP.NET development using Visual Studio Code on Mac OSX.

This article is published as part of the IDG Contributor Network. Want to Join?

ITWorld DealPost: The best in tech deals and discounts.