Chris Gomez

Development topics for the indie programmer

ASP.NET 5 on Ubuntu Linux "from scratch"

[Now on GITHUB!  I've started a GitHub repo for automating the setup of ASP.NET across platforms.  It currently supports Ubuntu and CentOS flavors, but I plan to keep testing and updating, and include an automated setup for Windows]

[Update: The following is working with ASP.NET beta 6 and was tested on August 22, 2015.  I'll try to keep the post updated, but for one thing I have seen in Announcements for beta 7 that they are changing the dnx command syntax so that may need to be updated in the future.]

[Update: August 22, 2015: I was having problems with dnu restore. The script has been updated to add an environment variable to .bashrc to give Mono more threads per cpu, which made dnu restore much more reliable.]

I've been working at getting ASP.NET 5 running on Linux.  This post doesn't replace the great work of the documentation at the ASP.NET repos at github, or the great work of those working on the Yeoman generators for aspnet.  This merely stands on their shoulders.

I wanted a single script I could use to bootstrap a Linux VM.  After working at it and testing again and again for a few days, here is the script I've come up with for now: Gist on Github

This follows the instructions (essentially) for installing mono, libuv, and dnvm.  Then it installs node and yeoman (remember, I am basing this on a clean install of Ubuntu 14.04 LTS) and puts you just a few steps away from running an ASP.NET template.

How clean is that Ubuntu install?

My Ubuntu installation for this test is via VirtualBox 5.0.2.  The host is Windows Server 2012 R2.  I did accept the third party software and didn't skip anything during the installation.  I let the system get all the Software Updates.  Then I installed the VirtualBox Guest Additions just to make things smoother.  Finally, I installed Atom text editor from

Getting the script

Method 1: Copy/Paste into Atom

If you enable the Shared Clipboard and at least Host to Guest (Bidrectional works too), I've opened the VM, opened atom and then copy and pasted the script home folder as

Then I run:


I had no interruptions other than needing to elevate for the sudo portions of the script right when it started.

Method 2: The one liner

Here, I copy the file down using wget (which seems to be preinstalled) and immediately run bash, but after authenticating for sudo elevation, I can walk away.

wget && bash

"How did this happen?" Q&A

1) Why not "sudo bash"?  Because the dnvm download in particular didn't really want to be installed as root.  I was much happier having that portion installed as my user.  Since the dnvm script updates .bashrc, if you download dnvm as root, you have trouble with the various utilities (dnvm, dnu, dnx) running in your user environment.

2) Why did you wget and then run via bash instead of piping curl output to bash?

A month ago, that sentence would have been meaningless to me.  I am not sure if it is truly literate or sounds like a first grader.  In any case, I really wanted to download and pipe the script to bash.  But what I found was, the script would halt after mono was installed.  I don't know why and I found that getting the file and then calling bash on it worked.  Why wget instead of curl?  No reason.  curl -L [url] > [filename] should work, too.

Script's Done

DNVM and the Mono environment won't be set up for you.  The shell will tell you it has no idea what dnvm is and you really need an environment variable set before you run dnu restore later.  The ASP.NET team's script adds dnvm to .bashrc, and after some reading, I decided to export the Mono environment variable there, too.  Let me know what you think about these choices.

You could always open a new shell but I found manually running:

source .bashrc

did what I wanted and I could continue on from here.

Now you take over

The script ends with mono, libuv, dnvm, node, yeoman, and the aspnet generators installed (along with dependencies).

You still need a version of aspnet to be installed (dnvm list shows none).  So:

dnvm install latest

After this was done, I still need to generate an ASP.NET 5 project using:

yo aspnet

So far I've tried the Console and WebApplicationBasic templates.  After one is created, it will give you a quick rundown of getting them running.  But for review:

First you need to cd to the folder you created the project in and restore NuGet packages:

dnu restore

Then finally, after all that I could run the Console application with (from beta 7 on, drop the period and use dnx run)

dnx . run

And I could run the WebApplicationBasic application with (from beta 7 on, drop the period and use dnx kestrel)

dnx . kestrel

Once the WebApplicationBasic template is running, point to http://localhost:5000 in your browser.

How does this work for you?  I greatly appreciate suggestions, as I'm coming over to Linux from a career spent in Windows.

A DevOps “Jump Start” Using Azure Web Sites and GitHub

Previously, I discussed that I started a side project to discover better ways to build “web apis”.  In this case, I am using ASP.NET Web API but I think the lessons I am after could be applied to many technologies and clouds.

One of the things I was looking for was some light continuous deployment after code is committed.  At the same time, I wanted to see what the process was to get different kinds of web sites, using different frameworks and technologies, running on Azure Web Sites

After all, the marketing says it supports .NET, Java, PHP, Node.js, and Python.  It also claims continuous deployment.  So is it faster, easier to use, and more fun?

What To Deploy?

I created a repository on GitHub called WebJumpStart for the purpose of testing out a few tricks Azure Web Sites has up its sleeve. 

In it, you will find three web sites. 

  • AspNetMvc is an ASP.NET 5 MVC site right out of the gate after File > New Project. 
  • HelloWorld is just static content files (simple html/js/css files). 
  • NodeExpress is the Node Express starter site, also unmodified (it is a bit out-of-date at this point, but the magic of npm ensures the versions I’ve picked in package.json are there for me to use).

Note that only one of these projects is based in ASP.NET.  HelloWorld and NodeExpress could have been built with notepad, Sublime Text, Brackets whatever…