Experiments with C# on a Mac.

By | 7 May, 2015

Noticing a pattern here….?

So task for tonight was to try and run a simple C# app on the Mac and since Microsoft Build ’15, they’ve announced a number of things to help people with any OS use MS tools.

So, first an editor. I’m using Microsoft Visual Studio Code. Its by no means the full Visual Studio suite, but it is a cool code editor with intellisense, a few debugging tools, and works nice on the Mac.

Second installing .Net.

We’re going to use a combination of open source tools to do this. First we need to install “Brew”. Brew is an open source package manager (think apt-get or yum, but for Macs).

Install this by doing (in a terminal):

ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

Now for the dotnet execution environment:

brew tap aspnet/dnx

Update Brew to make sure all versions are as up to date as possible

brew update

…and install some supporting dotnet tools (dot net version manager).

brew install dnvm
dnvm upgrade

Now for a few more tools. (Stick with it your nearly there….).

Using node (use the installer from nodejs.org if you haven’t go it) and install a node package called yeoman. Yeoman is a web scaffolder, ie. it create a lot of basic code using templates for common developer tasks.

npm install -g yo

…and also generator-aspnet (this is a command line wizard to create .net apps).

npm install -g generator-aspnet


Now we execute:

yo aspnet

You can pick from 1 of five different .net project types. We’ll Pick a console Application.

And then execute it!

dnu restore
dnu build
dnx . run for console projects
dnx . kestrel or dnx . web for web projects

Hello World!