Copyright
Getting Started with ASP.NET 5 for OS X, Linux, and Windows
Agus Kurniawan
1st Edition, 2015
Copyright 2015 Agus Kurniawan
Table of Contents
Preface
This book was written to help anyone want to get started with ASP.NET 5 core. It describes ASP.NET 5 core deploying and the basic elements of ASP.NET 5 core and shows how to work with several ASP.NET 5 core features.
Agus Kurniawan
Berlin & Depok, June 2015
1. Preparing Development Environment
1.1 ASP.NET 5
ASP.NET 5 is a lean and composable framework for building web and cloud applications. ASP.NET 5 is fully open source and available on GitHub, http://github.com/aspnet/home . ASP.NET 5 is currently in preview when this book is written.
This book will focus on how to develop ASP.NET 5 on OS X, Linux and Windows platforms. We use ASP.NET 5 core beta4.
1.2 System Requirements
For testing, I use Debian/Ubuntu Linux, OS X Yosemite and Windows 8.1. You can use any Linux distribution which inheritanced from Debian based.
1.3 Development Tools
In general, we can use any editor to write ASP.NET 5program. I recommend to use Sublime Text, http://www.sublimetext.com/ , to write ASP.NET 5 codes. Microsoft also released Visual Studio Code and you can download it on https://code.visualstudio.com/ .
2 Deploying ASP.NET 5 on OS X
In this chapter we will learn how to deploy ASP.NET 5 on OS X.
2.1 Getting Started
In this section we start to deploy ASP.NET 5 on OS X. In this book I use ASP.NET 5 preview, beta4. Please follow installation steps on next section.
2.2 Deploying ASP.NET 5
To install ASP.NET on OS X, you can use brew, http://brew.sh/ . Type these commands to install ASP.NET 5.
$ brew tap aspnet/dnx $ brew update $ brew install dnvm

If success, you can see a task which you should do. We must add dnvm on our profile.

Type this command.
$ nano ~/.bash_profile
Then, you get nano editor. You can use another text editor. Add this script on ~/.bash_profile.
source dnvm.sh

If done, save this file. After that, close your Terminal and then open again so Terminal will load profile script.
The next step is to upgrade. Type this command.
$ dnvm upgrade

Now you already installed dnvm. It will be used to manage ASP.NET 5 runtime on OS X. You can verify dnvm by typing this command.
$ dnvm help
So you see a list of dnvm parameter.

You can also see a list of your DNX runtime by typing this command.
$ dnvm list

2.3 Testing
To test our ASP.NET 5, we use code samples from https://github.com/aspnet/Home . We clone this code samples and then restore all required libraries using dnu command.
Type these commands.
$ git clone https://github.com/aspnet/Home $ cd Home $ dnu restore
If you don't git on your OS X, you can install it via brew.
$ brew install git

Now you are ready to run code samples.
2.3.1 ASP.NET Console
To run ASP.NET Console, we can use dnx. Firstly, navigate to ConsoleApp project.
Type these commands.
$ cd samples/latest/ConsoleApp/ $ dnx . run .
If success, you can see a message "Hello World" on Terminal.

2.3.2 ASP.NET 5
To run ASP.NET 5 app, we can use dnx with kestrel. Firstly, navigate to HelloWeb project.
Type these commands.
$ cd samples/latest/HelloWeb/ $ dnx . kestrel
Now open a browser and then navigate to http://localhost:5004/ . You should see ASP.NET 5 app.

To stop kestrel, you can type exit.
exit

2.3.3 ASP.NET MVC
To run ASP.NET MVC, we can use dnx. Firstly, navigate to HelloMvc project.
Type these commands.
$ cd samples/latest/HelloMvc/ $ dnx . kestrel
Now open a browser and then navigate to http://localhost:5004/ . You should see ASP.NET MVC app.

To stop kestrel, you can type exit.

2.4 Development Tools
The next step is to build program. To write a program, you can use any text editor. Microsoft also provides Visual Studio Code. It runs on Windows, Linux and Mac. You can download it on https://code.visualstudio.com/ .

3 Deploying ASP.NET 5 on Linux
In this chapter we will learn how to deploy ASP.NET 5 on Linux.
3.1 Getting Started
In this section we start to deploy ASP.NET 5 on Linux. In this book I use ASP.NET 5 preview, beta4. For illustration, I use Ubuntu 15.04 as Linux distro. Please follow installation steps on next section.
3.2 Deploying ASP.NET 5
This installation process is based on this documentation, https://github.com/aspnet/Home/blob/dev/GettingStartedDeb.md . In this section, we install ASP.NET 5 on Linux manually (without docker). Firstly, you update your distro.
$ sudo apt-get update
In general, to install ASP.NET 5 on Ubuntu, you can do the following steps:
- Installing Mono
- Installing libuv
- Installing DNVM
- Installing git (optional)
3.2.1 Installing Mono
Mono is .NET runtime for Linux. You need the latest version of Mono runtime. To install it, you can type these commands.
$ 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