[vNext] Install ASP.NET 5 (DNX) on Ubuntu

By | March 26, 2015

Advertisement from Google

ASP.NET MVC application on Linux? Easy!

As you may know, Microsoft recently released a lot of their products under MIT license. .NET Core runtime, .NET CoreFX, ASP.NET 5, MVC 6, Entity Framework 7, MSBuild, everything is now available on GitHub.

HighlightsvNext

Our goal is: run Asp.Net MVC application with postgresql database on ubuntu server

Today we are gonna start with setting up .NET environment.

In the new asp.net stack you can choose between full .NET runtime and .NET Core. For now .NET Core has a lot of limitations, so we gonna use mono.

Install mono

As described in official documentation:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete

Install .NET Version Manager (DNVM)

First we need to install .NET Version Manager

We use the .NET Version Manager to install different versions of the .NET Execution Environment (DNX) (used by the ASP.NET 5 runtime) and switch between them.

curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.k/kvm/kvm.sh

Install the .NET Execution Environment (DNX)

kvm upgrade

Advertisement from Google

This command will download the specified version of the DNX, and put it on your user profile ready to use. You are now ready to start using ASP.NET 5 with the DNX!

Compile and install libuv

sudo apt-get install gyp
wget http://dist.libuv.org/dist/v1.4.2/libuv-v1.4.2.tar.gz
tar -xvf libuv-v1.4.2.tar.gz
./gyp_uv.py -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.4.2
sudo ln -s /usr/lib//libuv.so.1.4.2 /usr/lib/libuv.so.1

Run ASP.NET MVC example

Clone asp.net home repository:

git clone https://github.com/aspnet/Home.git

Go to sample:

cd Home/samples/HelloMVC

Restore all required packages with:

kpm restore

Now you can run your MVC application

k kestrel

Go to  http://127.0.0.1:5004 and see the result.

In next part we are gonna install PostgreSQL with NHibernate and add web api methods to our application.

Next Part: “[vNext] Use PostgreSQL + Fluent NHibernate from ASP.NET 5 (DNX) on Ubuntu

10 thoughts on “[vNext] Install ASP.NET 5 (DNX) on Ubuntu

  1. Mike Wallace

    This is exactly what I’ve been looking for! Looking forward to the next post.

    Reply
  2. naji hadar

    Isn’t this just running mono in some wrapper?
    where is the infamous core clr?

    Reply
  3. Mailson

    Can you help me?
    I followed the tutorial step by step and when I run gave following error:
    System.InvalidOperationException: Unable to load application or execute command ‘Microsoft.AspNet.Hosting’. Available commands: web, kestrel.
    at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundException (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.Exception innerException) [0x00000] in :0
    at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in :0
    at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in :0

    Reply
  4. Antonio Rezende Neto

    Just don’t forget to mention that one has to have “build-essential” and “git” installed.

    The following link form your tutorial has “&” instead of the “&” symbol:
    curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.k/kvm/kvm.sh

    Another point that I would correct is the following:

    sudo apt-get install gyp
    wget http://dist.libuv.org/dist/v1.4.2/libuv-v1.4.2.tar.gz
    tar -xvf libuv-v1.4.2.tar.gz
    cd libuv-v1.4.2 <—————————————————————————————– INCLUDE THIS STEP HERE
    ./gyp_uv.py -f make -Duv_library=shared_library
    make -C out
    sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.4.2
    sudo ln -s /usr/lib//libuv.so.1.4.2 /usr/lib/libuv.so.1

    And for those who are experiencing problems like:

    System.InvalidOperationException: Unable to load application or execute command 'Microsoft.AspNet.Hosting'. Available commands: web, kestrel.
    at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundException (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.Exception innerException) [0x00000] in :0
    at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in :0
    at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in :0

    Change all the “beta4” to “beta3” in project.json file then do “kpm restore” followed by “k kestrel” in the same directory of the project.json file.

    It was all that it took to accomplish that!

    Cheers and thanks 😉

    Reply
  5. manuel

    Esto que se describe aqu{i todav{ia no funciona,…revisandolo y dandole demasiadas vueltas incluso. estos comandos no funcionan “kpm restore” followed by “k kestrel”. (justo al finalizar la receta).

    Reply
  6. Alexander Pring

    In fact no matter if someone doesn’t know afterward its up to other visitors that they will assist, so here it happens.

    Reply
  7. Rory McBryde

    Remarkable things here. I am very glad to see your post. Thanks a lot and I’m looking ahead to touch you. Will you please drop me a e-mail?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *