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
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
kestrel command. As an example:
As you can see in this
kestrel is exposing a service
5004. Later on, you will see that Yeoman templates are usually
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.
You will need to start by installing Node.js. You can check the Node.js version to see if it is installed already:
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!
Make sure you checkout out the Github repo to see what other templates are available outside of just the projects listed in the generator.
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:
- Building your first application
- Entity Framework 7 and it’s currently supported providers
- Running the .NET Core on Ubuntu
If you have any questions, problems, or suggestions please reach out to me on Twitter or through email at email@example.com.