Hi, I'm Matthew Cantelon

I am a web developer that specializes in ASP.NET development but I have lots of experience working with Wordpress and Golang. If you're looking to build a custom application to better serve your customers or to improve your site usability, reach out to me at hey@matthewcantelon.ca.

Getting Started With ASP.NET 5 On Linux

This is the setup procedure for installing ASP.NET 5 on Linux using Mono. The team at Microsoft has put together some good documentation so I will link those and provide tips on parts that don’t work as well or that have changed.

Installing the required software

Documentation: [http://docs.asp.net/en/latest/getting-started/installing-on-linux.html]

In the documentation, you have two options: Docker or local. Personally, I setup both environments so that I could easily test locally and deploy to my VM later. I would suggest going through the local install process first.

Tips for local

There really aren’t any! Just follow along with the instructions and you will have everything installed to run an ASP.NET 5 project. Your next big problem will be creating them, which is a little bit different than what you might be used to if you come from Visual Studio. We’ll talk about setting up Yeoman a bit later in this post.

Tips for Docker

If you followed the links in the documentation, you end up at a MSDN blog post. The information here is a little out of date so here is a working Dockerfile:

FROM microsoft/aspnet

COPY . /app
WORKDIR /app
RUN ["dnu","restore"]

EXPOSE 5004
ENTRYPOINT ["dnx",".","kestrel"]

As you can see, the applications have changed so now the correct ones are being called. Also worth pointing out, you may need to change the port that is exposed. Whatever application you are using to test with, I will assume one of the samples, make sure to look in the project.json file and expose the port that is showing under the kestrel command. As an example:

"commands": {
  "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001",
  "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004"
},

As you can see in this project.json excerpt, kestrel is exposing a service on port 5004. Later on, you will see that Yeoman templates are usually running on 5001.

Making applications

So you have your environments setup but what about actually creating a project? It isn’t too bad as the Omnisharp team has supplied a set of Yeoman templates.

Install tooling

You will need to start by installing Node.js. You can check the Node.js version to see if it is installed already:

node -v

If it is not installed, you can run:

sudo apt-get install nodejs

Next, you can use NPM to install Yeoman and the template generator:

npm install -g yo generator-aspnet

And when that is all done, you can build applications from the templates!

yo aspnet

Make sure you checkout out the Github repo to see what other templates are available outside of just the projects listed in the generator.

The end

You now have an environment to build projects from! For me this is really just the beginning as I plan to write more about using ASP.NET 5 on Ubuntu. Things I would like to cover:

If you have any questions, problems, or suggestions please reach out to me on Twitter or through email at fml@matthewcantelon.ca.