Asp.net on Linux: Part 1: Setting up the environment
- Asp.net on Linux: Part 3: Creating the project
- Asp.net on Linux: Part 2: Editing
- Asp.net on Linux: Part 1: Setting up the environment
- Asp.net on Linux: Introduction
Base system
I’m starting with a default install of Linux Mint 17.1 that’s been fully patched. We’ll be using DNX Version Manager (DNVM) for managing our Asp.net sites and Gulp to build and run various tasks, so we’ll need to make sure we’ve got all the prerequisites for these to work. I’m going to assume you’re working from a similar starting point, but if you already have some of the required software (like curl, for example), just skip the step that installs it.
Prerequisites
There are quite a few packages that need to be installed in order for everything else to work and it’s simplest to get them all at once.
Now, we need to get an updated version of libuv because the current implementation of Kestrel, a simple web server, requires a version of libuv that is not in the Linux Mint package manager. I’ve got each step listed separately to help troubleshoot if anything goes wrong.
Configure git
We’ll be using git to manage our source and deploy our application. Many package managers can use git to pull down packages as source as well.
Since we already installed git in the step above, we just need to do some basic configuration. For more configuration options, see the getting started section of the git book.
Get Node.js
I prefer to use NVM to manage node.js, and to get it you should run the following command:
Running this will put the following block of code in your .profile file:
This only gets executed if you run a login shell, which Mint does not do by default. So I move those two lines out of my .profile and into my .bashrc file. Since .profile executes .bashrc, this seems pretty safe to do. Either source your .bashrc file or reopen your terminal window and run:
You should see a version number if everything installed correctly. Now we can use it to install a version of node.js:
Running node --version
just verifies that it is installed and usable.
Get Mono
I’m going to use the Xamarin packages for Mono because they’re the official and most up to date stable releases.
First, we need to add the GPG keys so we can trust the packages from Xamarin’s repository:
After adding the keys, we can add the repository to the list of available package repositories and then update the available packages:
Finally, we can install mono:
I’m writing this at the Kalahari on the last night of CodeMash, so this step took awhile over the hotel wifi. Once it finishes, you should be able to check the version to verify it’s installed:
Get DNVM
Now we’ll get the dnx version manager and use it to install dnx. Installing it follows the same pattern as NVM: download a script and pipe it into a shell to execute immediately:
Either source your .bashrc or reopen your terminal window and run the next set of commands.
Let’s Test!
To verify that everything works, we’re going to run the HelloMvc application from the asp.net samples folder. Let’s get that now.
Now we’re going to restore all the packages needed to run the application. This took a few minutes on my laptop, but it is about 7 years old.
When the restore finishes, it’s time to see if all our work has paid off!
After you see ‘started’ in the output, open a browser and go to http://localhost:5004. If you see the standard asp.net welcome page, congratulations: you can now run asp.net applications on Linux!
Next time, we’ll set up our editing environment.