In this installment, we’ll be getting our Ubuntu environment set up for ASP.Net Core development. I’m using an Ubuntu 14.04 VM on my Mac. If you choose a different Linux installation, hopefully this will help, but mileage may vary.
Ubuntu
This will just be a short article on getting your development environment set up. For this article, I’m using Ubuntu 14.04 desktop edition. I’m working on a Mac and running Ubuntu as a VM via VMWare fusion. Here’s some good instructions on getting this set up…not much to it really although their Ubuntu download link has gone bad.
Open a command line and make sure out package manager is up to date:
apt-get update
or if needed, prefix with sudo as shown below.
sudo apt-get update
In the commands that follow, I’m assuming that if you run into security issues you will use sudo to prefix installation steps. The exception is when installing Node/NPM. Here we want to avoid using sudo which is why I use the specific technique
Now make sure that Unzip and cURL are installed (again prefix with sudo if required).
apt-get install unzip curl
Visual Studio Code
Visual Studio Code is just a download and install. Just make sure you download the .deb installer if you are using Ubuntu. This will take you to the Ubuntu Software Center and prompt you to install Visual Studio Code. In my case, the installer warned my that it didn’t like the package for Code…I proceeded anyway and it installed just fine. Not sure what the deal is there…this is the just-release 1.0 drop of Visual Studio Code…so maybe just a glitch in the installer…but again it appeared to install just fine without a hitch. In addition, the installer should also set up launching from the command line via typing “code {your directory here}” to launch in the specified directory.
After starting up Visual Studio Code, assuming you are using the Unity GUI, you will see the Visual Studio Code icon in the Launcher Bar on the left side. You may want to right click the Code icon and select Lock to Launcher so the icon stays put when Code is closed.
In order to support C# development, we’ll be adding the OmniSharp plugin. Basically you can hit F1 to bring up the Command Palette and then type/select Install Extension from the command selections. Then choose/type C# from the available installations. In a few seconds, OmniSharp will be installed but a restart of Code will be necessary to complete installation. Here are the official instructions.
Node
Of course Node is required for build and scaffolding tools etc… For this demo I’ve installed Node 4.4.3 but don’t believe there should be any issues using 5.x. I used the NVM method to install Node. This method is being used because it allows node packages to be installed globally without requiring sudo permissions.
The full instructions are here.
The Basics
Open a command line and run the following.
curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
Restart your command line.
To install Node/NPM with NVM:
nvm install 4.4.3
And now we need to install some build tools to help us out via NPM. The execution of these commands should not require sudo to install if the NVM method worked properly.
npm install -g yo bower grunt-cli gulp
Installing .Net
Now we’re going to install .Net tooling to allow us to control the various .Net runtime versions on our system. Note that this tooling will change when RC2 comes out. I’ll update this post when V2 officially drops. The information below was taken mostly from this source.
To install the .Net Version Manager (DNVM):
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
To install other .Net prerequisites via the Ubuntu package manager:
sudo apt-get install libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev uuid-dev
Now we’re going to use the DNVM to install the latest DNX available for the Core CLR. This is a compact, performant, and cross-platform version of the common language runtime (clr) that we will be using.
dnvm upgrade -r coreclr
ASP.Net core applications run on a lightweight and performant web server called Kestrel that uses a cross-platform I/O library called Libuv. The following builds and installs Libuv:
sudo apt-get install make automake libtool curl curl -sSL https://github.com/libuv/libuv/archive/v1.8.0.tar.gz | sudo tar zxfv - -C /usr/local/src cd /usr/local/src/libuv-1.8.0 sudo sh autogen.sh sudo ./configure sudo make sudo make install sudo rm -rf /usr/local/src/libuv-1.8.0 && cd ~/ sudo ldconfig
Docker
We’ll be using docker as our method of packaging and deploying our ASP.Net applications. The instructions to install Docker on Ubuntu can be found here. Make sure you follow all instructions for Ubuntu 14.04 (or whichever version you are using).
Yeoman Templates
If you followed the Node instructions above, you’ve already installed Yeoman from NPM. All we need to do now is install our ASP.Net yeoman templates to get us started:
npm install -g generator-aspnet
The GitHub repository has much more thorough information.
That’s it as far as getting set up for now. In our next installment, we’ll build our first ASP.Net Web API on Linux that targets the core framework.