Running ASP.NET on Ubuntu

I wanted to run .NET on linux since I’ve seen people talking about it so much recently. I couldn’t find a start-to-finish tutorial though so I am attempting to do that here.

  1. In VMWare Workstation (you can use VirtualBox just the same) create a VM and install the latest version of Ubuntu desktop.
  2. Once installed and you login, update everything that needs updating in the Ubutntu Software Center and reboot
  3. Type everything in the sub-lists below as commands in a terminal…
  4. Install Mono: 1. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  5. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
  6. sudo apt-get update
  7. sudo apt-get install mono-complete
  8. Install libuv: 1. sudo apt-get install automake libtool curl
  9. curl -sSL https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv - -C /usr/local/src
  10. cd /usr/local/src/libuv-1.4.2
  11. sudo sh autogen.sh
  12. sudo ./configure
  13. sudo make
  14. sudo make install
  15. sudo rm -rf /usr/local/src/libuv-1.4.2 && cd ~/
  16. sudo ldconfig
  17. Install the .NET Version Manager (DNVM): 1. curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
  18. Install the .NET Execution Environment (DNX): 1. dnvm upgrade
  19. More installs for the next part: 1. sudo apt-get update
  20. sudo apt-get upgrade
  21. sudo apt-get install build-essential openssl libssl-dev curl git
  22. Install NVM: 1. git clone git://github.com/creationix/nvm.git ~/.nvm
  23. To load NVM whenever a terminal is opened: 1. echo '[[ -s "$HOME/.nvm/nvm.sh" ]] && source "$HOME/.nvm/nvm.sh"' >> ~/.bash_profile
  24. Start NVM in the current terminal: 1. . ~/.nvm/nvm.sh
  25. Install Node.js (0.12.6 is the latest version as of this post, you should replace this with whatever the current version is when you install it): 1. nvm install v0.12.6
  26. nvm alias default 0.12.6
  27. Install Yeoman (Yo) and the scaffolding template for ASP.NET projects: 1. npm install -g yo generator-aspnet
  28. Generate an empty ASP.NET project. A wizard will come up and ask you what type of project you want to create. I created a Simple website and named it “MyFirstDotNetAppOnLinux”: 1. yo aspnet
  29. Switch to the new directory/template that was created: 1. cd MyFirstDotNetAppOnLinux
  30. dnu restore
  31. Start Web Server: 1. dnx . kestrel
  32. Open Firefox and go to http://localhost:5000
  33. To kill the web server hit Ctrl+Z then enter kill %1

Here are the articles I referenced when putting together this start-to-finish guide:

Don’t forget to install Visual Studio Code so you can edit your project in Ubuntu!